Java代理服务器HTTPS请求转发

时间:2015-04-28 05:35:03

标签: java sockets http https proxy

我正在开发一个java web服务器代理,用于http和https请求。我的服务器适用于http请求,但我不能为Https请求做出... 浏览器向我发送CONNECT请求,但在将其转发给目标时,我没有任何数据......你能帮助我吗?

这是我的代码

socket = new Socket(host, 443);

// send connect message to httphost
toServer = socket.getOutputStream();
toServer.write(buffer, 0, buffer.length);
toServer.flush();

fromServer = socket.getInputStream();
toClient = sock.getOutputStream();
byte[] responseBuffer = new byte[1024];
int j = 0;
while ((j = fromServer.read(responseBuffer)) > 0) {
    toClient.write(responseBuffer, 0, j);
    toClient.flush();
}

toClient.close();
fromServer.close();

0 个答案:

没有答案
相关问题