java代理服务器https请求转发

cwtwac6a  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(195)

我目前正在为http和https请求开发一个java web服务器代理。我的服务器可以很好地处理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();

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题