简体   繁体   中英

Java HTTP Proxy thought Socket connection

I would like to to make a http request though a socket connection.

Here's how I am forming my proxy.

SocketAddress addr = new InetSocketAddress(proxyHost, proxyPort);
Proxy proxy = new Proxy(Proxy.Type.HTTP, addr);
socket = new Socket(proxy);

If I change the proxy type to socks and point it to a socks proxy, then it works. So I am not too sure why it's not working when I set the type to http and point it to an http proxy server.

The error I receive lies within the Socket.class and the error is Invalid Proxy.

The socket.class didn't allow http. Socks worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM