Open seanakdh opened 3 weeks ago
Hello, thank you for the comment. I really appreciate it 😊 Unfortunately I still don't understand why you need to make HTTP request out of TCP stream.
I think you mean HTTPResponse
. If so - you're right, my implementation cannot handle TCP stream properly. The reason is that (as you mentioned) There may not be EOF in TCP stream. I have another repository, that tackled the issue (here). I also wrote about it in my blog.I hope this helps your project.
Now I get it. Yeah from a server stand point it for sure needs to parse the request out of TCP stream. I'll think about it in my spare time 😄
I'm just learning, so thank you very much for your examples.
I've noticed that the implementation of try_from for the HTTPRequest blocks after generating the headers when used on a BufReader created with a TcpStream. This also happens with the code in your repo, not only my implementation.
Specifically, on the .peek() part in this code:
So far I don't understand why, I assume because it awaits further bytes since when I cancel the request it finishes up. Probably awaits an EOF, which you get when reading a file, but not with the HTTP protocol.
Is this TryFrom implementation for BufReader really feasible when there is no EOF? How else would you handle this?
Any insight would be appreciated.