Fix responses from non-compliant HTTP server #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Not all HTTP servers follow the HTTP protocol standard that requires headers to be CR+LF terminated.
Some servers do not send CRLF at the end of lines but just LF, some others produce a mix of headers ending in CRLF or LF.
The response from such servers is not supported by this library, and thus the library fails to product a reliable response.
HTTP standard allows for such behaviour (see Message Parsing Robustness) and recommends reading lines till the LF and discard any CR.
This PR tries to mitigate this issue. It was detected while getting responses from the private API of ZTE MF65 4G MIFI router. The server responses didn't include a CR+LF on every header, only some of them included the CR+LF but others include only LF.
Here it is the output of
curlusing--trace -option on one of those routers:Cache-controlheader ends in LF (0xa) whileServerheader ens in CRLF (0xd 0xa).