hyper icon indicating copy to clipboard operation
hyper copied to clipboard

Different behavior on invalid URIs between HTTP/1 and HTTP/2

Open kolbma opened this issue 3 years ago • 3 comments

Version v0.14.16

Platform Linux

Description When requesting an invalid Uri like GET %2Fhello%2Fworld on an hyper HTTP/1.1 connection the service function doesn't get called and hyper itself returns a BadRequest reponse.

In a HTTP/2 connection the hyper.uri is set to something like http://127.0.0.1:8000%2Fhello%2Fworld (without slash after port) and this gets passed to the service function.
hyper.uri.path_and_query() makes from this magically /%2Fhello%2Fworld (now with slash).

I tried this code:

https://github.com/kolbma/rocket-issues/tree/main/issue1994

I expected to see this happen: hyper should handle it with HTTP/2 the same way like with HTTP/1.1

Instead, this happened: See description

kolbma avatar Jan 16 '22 17:01 kolbma

To clarify, do you mean sending a request with hyper::Client? Or do you mean receiving a request with hyper::server?

seanmonstar avatar Jan 18 '22 23:01 seanmonstar

It is on server side... Webframework Rocket uses hyper as its base...
Here https://github.com/SergioBenitez/Rocket/blob/8cae077ba1d54b92cdef3e171a730b819d5eeb8e/core/lib/src/server.rs#L459-L465
the service_fn is called on an invalid URI with HTTP/2 while hyper aborts this with HTTP/1.1 with a BadRequest and doesn't call the service_fn.

kolbma avatar Jan 19 '22 09:01 kolbma

Perhaps related to https://github.com/hyperium/http/issues/507 https://github.com/hyperium/http/pull/515

olix0r avatar Jan 19 '22 20:01 olix0r