eidheim / Simple-Web-Server

A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio. Created to be an easy way to make REST resources available from C++ applications.
MIT License
2.61k stars 751 forks source link

Support for incorrect (but tolerated) line endings #202

Closed sharpie7 closed 6 years ago

sharpie7 commented 6 years ago

Lines in HTTP headers should end with CRLF according to the specification. In particular there is a double CRLF to mark the end of the headers. Simple-Web-Server uses the CRLFCRLF as a delimiter to read the headers from ASIO (server_http.hpp line 438).

I note that the HTTP spec recommends: " The line terminator for message-header fields is the sequence CRLF. However, we recommend that applications, when parsing such headers, recognize a single LF as a line terminator and ignore the leading CR." (RFC2616 section 19.3 - "Tolerant Application")

Currently the HTTP server doesn't support this recommendation in the RFC.

EDIT: Now found this is not the problem, kept to set the original context: I am not sure because I am trying to debug someone elses implementation remotely, but I think it is possible that I have encountered an HTTP client that doesn't use the correct line endings and therefore has requests silently discarded by simple-web-server.

sharpie7 commented 6 years ago

Edit to add: The problem I have isn't line endings, so I think this is a low priority.

eidheim commented 6 years ago

Ah good to hear, I was considering this and it would be possible to use http://www.boost.org/doc/libs/1_66_0/doc/html/boost_asio/reference/async_read_until/overload3.html, but it would add some complexity and a slight runtime overhead.

sharpie7 commented 6 years ago

Thanks, but don't relax too much. I think I now know what the real bug is, and it could be interesting. Will create a new issue once I confirm!