3

I'm building a proxy service in rust with hyper and I want to support both HTTP1 and HTTP2 requests. If I send a request where request.version() == "HTTP/2.0".to_owned() I get the warning

WARN  hyper::client::client  "Connection is HTTP/1, but request requires HTTP/2"

followed by the error

request has unsupported HTTP version

If I build my hyper::Client with client_builder.http2_only(true) I can send http2 requests, but that method clearly states that I won't be able to send http1 requests, which I still want to support. The documentation and the code in hyper::client::Builder seems to imply that it supports HTTP1 and HTTP2 by default (if the http2 feature is enabled) by it's client_config.ver field is either Ver::Auto or Ver::Http2.

I dug deeper into the code that gave the above warning and I see that it's checking if the pooled connection is HTTP1 and erroring if the request is also HTTP2. I'm seeing no way to make that connection HTTP2 short of forcing everything to be HTTP2 with only_http2.

Is it really impossible for a hyper::client::Client to support sending http2 and http1 requests? Must I maintain two separate clients and branch on the requests version?

cheezsteak
  • 2,731
  • 4
  • 26
  • 41

0 Answers0