-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Hyper server violates HTTP/1.0 compatibility (keep-alive, transfer-encoding) #1304
Description
Hyper will answer an HTTP/1.0 request as if it were an HTTP/1.1 request. This includes the following violations:
- Hyper server sets the response version to
HTTP/1.1even forHTTP/1.0requests - Hyper server will enter into keep-alive mode without sending
Connection: keep-aliveto the client - Hyper server will use
Transfer-Encoding: chunkedregardless of client version
All of these items violate backwards compatilbility. An HTTP/1.1 server should be backwards compatible. Failing that I suggest that Hyper instead drops the connection, but I hope backwards compatibility could be achieved without too much trouble.
For keep-alive: HTTP/1.0 has support for parts of the keep-alive functionality, but for backwards compatibility it is sufficient to completely disable it when the request is of version 1.0.
For chunked transfer encoding: This is fundamentally not available in HTTP/1.0. However, streaming responses are possible by sending the body directly and terminating the TCP connection when completed. (This is a hopeless design, which is how we came to HTTP/1.1 in the first place)
Do we still need HTTP/1.0 compatibility? I stumbled onto this problem when benchmarking my server with apachebench, which only supports HTTP/1.0. Nginx also surprisingly defaults to using version 1.0 when talking to backend servers as a reverse proxy, though it can be configured to use HTTP/1.1 (and maybe even 2 these days?)
Are there workarounds? It is possible to run the server behind a reverse proxy that is correctly backwards compatible with clients, but still uses HTTP/1.1 to communicate with the backends. Nginx is an example of this. (If you configure it correctly)