Question

I am developing a proxy using Apache HTTP Components 4.

When a browser wants to open an SSL connection through my proxy it sends a request with the HTTP CONNECT method.

How can I implement the CONNECT method using HTTP Components? How can I turn the HTTP connection (which is already handled by the HTTP components library) into a raw TCP connection that is proxied through my program?

Was it helpful?

Solution

Once a connection tunnel has been negotiated (CONNECT handshake has been successfully executed) and outgoing connection successfully established, your proxy should bypass the entire HTTP layer and start reading whatever stuff comes from the raw socket of the incoming connection and copying it to the raw socket of the outgoing connection, as well as reading whatever stuff comes form the socket of the outgoing connection and copying it to the socket of the incoming connection.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top