While in principle you could modify the CONNECT proxy, you probably want to produce an entirely separate proxy for cleartext HTTP traffic.
When proxying cleartext HTTP, instead of using a special magic request to ask for a tunnelled connection you instead reformat the request to be sent to a proxy. To do this you need to compute the request target from the HTTPRequestHead
. This is usually communicated in three parts:
- The scheme is communicated by the fact that you're sending plaintext data, so it'll be
http://
- The host portion of the URI is communicated in the
Host
header. - The path and query portions are in the
uri
field of theHTTPRequestHead
.
You then replace the uri
field of the HTTPRequestHead
with the computed request target URL. This tells the proxy where it should be forwarding the request to.
This is basically completely unlike what you do for the CONNECT proxy. You absolutely could extend it, but in principle it may be easier just to construct a different handler.