How to use HTTP CONNECT to proxy plaintext requests

I have an HTTP Proxy configured that only accepts HTTP CONNECT requests to proxy requests to upstream servers, with some upstream servers using HTTPS and some using HTTP. However, the behavior in around line 1638 makes it so that HTTP CONNECT tunnels are only used when the request URL uses the “https” scheme. My code currently sets the Proxy field on the http.Transport struct to send requests through my proxy server, and all works as expected for requests using the “https” scheme, but it’s not doing so for the requests using “http”.

Since the purpose of HTTP CONNECT is to create a TCP connection to the upstream server and then proxy bytes over the connection, it seems equally useful for both HTTP and HTTPS upstream servers, however I haven’t found a way to get this behavior using http.Transport. Is my only option to copy much of the implementation within http.Transport, or is there a way to signal that I’d always like to use HTTP CONNECT to proxy these requests? Supporting schemes like “http+connect” and “https+connect” seems like a fairly natural way to signal this without breaking the current interfaces.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.