i already have a working HTTP proxy server that can handle multiple HTTP request. now my problem is how do I handle https request?
here\'s a simplified code i am us
I finally got it.
I only need to use normal socket and send a message to client that a connection is established. then proceed to tunneling.
here is a working code:
private Socket socket = null;
private Socket remoteSocket = null;
private HTTPReqHeader request = null;
ClientHandler(Socket socket)
{
this.socket = socket;
request = new HTTPReqHeader();
request.parse(socket); // I read and parse the HTTP request here
}
public void run()
{
remoteSocket = new Socket(request.url,request.port);
if(request.isSecure() )
{
// send ok message to client
String ConnectResponse = "HTTP/1.0 200 Connection established\n" +
"Proxy-agent: ProxyServer/1.0\n" +
"\r\n";
try
{
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
out.writeByte(ConnectResponse);
out.flush();
} catch(Exception e) {}
}
// start connecting remoteSocket and clientSocket
...........
}
here's a good explanation on how proxy server handles CONNECT. http://curl.haxx.se/rfc/draft-luotonen-web-proxy-tunneling-01.txt