x/net/http2: expose streams as net.Conn #26574
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
I’d like to have a way to expose individual streams as a net.Conn so I can implement a proxy that keeps a persistent HTTP/2 tunnel to an endpoint, receives HTTP/1 connections, and sends them to the remote endpoint through the HTTP/2 tunnel. In this way I can share 1 tcp connection with several streams.
Background
I’m trying to implement something like this:
So E1 would be a proxy server that keeps a connection to E2. Ideally, clients would send a regular CONNECT request to E1 and then the rest of the connection would be relayed through the HTTP/2 tunnel to E2 as HTTP/2 streams.
In regular proxies, I’d open a new TCP connection to E2 per
CONNECT
request and then just copy data betweenreq.Body
and the new TCP connection and vice-versa. In this case I want the HTTP/2 connection to be established already and just use a new stream perCONNECT
request.I tried implementing a custom
ClientConnectionPool
so I can get aClientConn
still in the pool but that only exposesRoundTrip()
which I’m not sure how to use in this case: I have ther.Body
from the client but how do I create a new Request with it so it gets sent viaRoundTrip()
? I saw this #17227 (comment) saying this feature would be kinda useless but I’m not sure I understand how to apply that to my use case, maybe I’m missing something obvious.The text was updated successfully, but these errors were encountered: