In educational purposes I'm writing a HTTP server in C++.
When receiving a request, how do I know when the client has finished sending headers? Is there an obligation that all headers must be sent in one shot? What if a client sends G
, then after 5 seconds E
, then T
..? Should I wait a timeout and just close the connection if it takes too long? Should I start parsing as soon as I get the first bytes to know if the request is invalid?
I know there are a lot of libraries for this, I'm just reinventing the wheel to better understand how the Web works at different layers. And I can't find how they deal with exactly my question.