NOTE. this should remain a private function. If get_content_length is added to Raxx module that should still only return nil | integer because the assumption is a Request or Response is always valid.
Checklist
[x] Add doctests to both functions
[x] update changelog
[ ] update Ace because the API for HTTP1.parse_request will now have a new failure case
Further
The parser should never error, content received over the net can be anything.
When this issue is closed a follow up issue can be to check the rest of the parser for failure cases.
This applies to both
parse_request
andparse_response
Desired behaviour
current behaviour is to crash.
Suggestion
change this function to
fetch_content_length
that returns{:ok, nil | non_neg_integer} | {:error, :invalid_content_length
https://github.com/CrowdHailer/raxx/blob/master/lib/raxx/http1.ex#L743-L751NOTE. this should remain a private function. If
get_content_length
is added to Raxx module that should still only returnnil | integer
because the assumption is a Request or Response is always valid.Checklist
Further The parser should never error, content received over the net can be anything. When this issue is closed a follow up issue can be to check the rest of the parser for failure cases.
https://tools.ietf.org/html/rfc7230#section-3.3.3 explains the details of parsing. Things that should be checked are sending case insensitive transfer encodings. multiple content_length headers