benoitc / hackney

simple HTTP client in Erlang
Other
1.34k stars 427 forks source link

Status codes as floats #697

Open luoken opened 2 years ago

luoken commented 2 years ago

There seems to be some sites that return status codes as floats e.g. http://www.lowiqcanadian.com/id2.html.

When running curl --head http://www.lowiqcanadian.com/id2.html we see that the status code returned is actually a 401.1 and hackney does not like that as it tries to convert the float into an integer.

Here are some status codes that are floats: https://docs.microsoft.com/en-us/troubleshoot/iis/http-status-code

tsloughter commented 2 years ago

I was curious about this because the HTTP spec defines the status code as 3 digit integer. I wouldn't be surprised that IIS breaks the spec but when I curl that url I get a 404.

Either way I don't think hackney should support it but I'm curious to see if it actually returns 401.1 and that is able to be handled by curl.

benoitc commented 2 years ago

The spec indeed defines it as a 3 digit integer : https://datatracker.ietf.org/doc/html/rfc7231#section-6

This is a low priority actually to support microsoft insanity and will come after the new connection engine but i think this can be done. Of course Microsoft pushed the insanity to the point it can be more than one digit after which makes things slower to check but we can actually parse it digit by digit. It will be slower though.