Is it doable to convert requests/responses between HTTP/1.1 and HTTP/2 in Hyper? #3404
-
I'm writing an HTTPs interception proxy and am exploring the possibility to convert between HTTP1.1 and HTTP/2 in Hyper. I don't have a solid grasp of HTTP/2 yet, but looking at the APIs, it seems that http2::SendRequest uses the same hyper::Request for both http1 and http2, but the headers are of different types. I'm thinking about swapping http1 headers and values with their http2 counterparts, and vice versa, but I'm not sure about the body. From what I know, HTTP/2 has multiple streams within a TCP connection, and transfers data by "frames". I wonder if the response body coming from a http2 Connection can be passed to a Service of a http1 Connection. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yes, you can mostly just pass-through the request from one version to another. hyper will handle encoding/decoding the headers and body according to the way the protocol version requires. The only thing you'd really need to do is check for a few headers that might come via HTTP/1.1 that are no longer allowed in HTTP/2 (like |
Beta Was this translation helpful? Give feedback.
Yes, you can mostly just pass-through the request from one version to another. hyper will handle encoding/decoding the headers and body according to the way the protocol version requires. The only thing you'd really need to do is check for a few headers that might come via HTTP/1.1 that are no longer allowed in HTTP/2 (like
connection
). Well, that and anything else expect of a transparent proxy.