1
我正在看JHttpTunnel庫,這片在OutBoundSocket.java代碼讓我有點糊塗了。HTTP隧道如何工作?
public void connect() throws IOException{
close();
String host=getHost();
int port=getPort();
String request="/index.html?crap=1 HTTP/1.1";
Proxy p=getProxy();
if(p==null){
socket=new Socket(host, port);
request="POST "+request;
}
else{
String phost=p.getHost();
int pport=p.getPort();
socket=new Socket(phost, pport);
request="POST http://"+host+":"+port+request;
}
socket.setTcpNoDelay(true);
in=socket.getInputStream();
out=socket.getOutputStream();
out.write(request.getBytes());
out.write(_rn);
out.write(("Content-Length: "+getContentLength()).getBytes());
out.write(_rn);
out.write("Connection: close".getBytes());
out.write(_rn);
out.write(("Host: "+host+":"+port).getBytes());
out.write(_rn);
out.write(_rn);
out.flush();
sendCount=getContentLength();
}
這似乎直接打開一個套接字服務器。通過防火牆阻止這個?