We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
this method works fine when the url contains http, but it wouldn't works when the url contains https. for example: works fine: getResponse(new URL("http://www.worldjournal.com/")); don't work: getResponse(new URL("https://google.com/")); public static String getResponse(URL url){ String result = ""; StringBuilder builder = null; InputStream inputStream = null; OutputStream outputStream = null; Socket socket = null; int length = 0; byte[] buffer = new byte[1024]; try { SocksProxy proxy = new Socks5("x.x.x.x", 1080, new UsernamePasswordCredentials("x", "x")); socket = new SocksSocket(proxy, new InetSocketAddress(url.getHost(), url.getPort())); inputStream = socket.getInputStream(); outputStream = socket.getOutputStream(); PrintWriter printWriter = new PrintWriter(outputStream); printWriter.print("GET " + url + " HTTP/1.1\r\n"); printWriter.print("Host: " + url.getHost() + "\r\n"); printWriter.print("\r\n"); printWriter.flush();
builder = new StringBuilder(""); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String line = null; while ((length = inputStream.read(buffer)) > 0) { System.out.print(new String(buffer, 0, length)); builder.append(new String(buffer, 0, length)); } inputStream.close(); outputStream.close(); } catch (IOException e) { e.printStackTrace(); } return builder.toString(); }
The text was updated successfully, but these errors were encountered:
Sorry, SocksSocket dose not support SSL because it's super class is java.net.Socket.
SocksSocket
java.net.Socket
Sorry, something went wrong.
javax.net.ssl.SSLSocket were the super class for SocksSocket, the https url would be supported in theory?
Yes.
No branches or pull requests
this method works fine when the url contains http,
but it wouldn't works when the url contains https.
for example:
works fine: getResponse(new URL("http://www.worldjournal.com/"));
don't work: getResponse(new URL("https://google.com/"));
public static String getResponse(URL url){
String result = "";
StringBuilder builder = null;
InputStream inputStream = null;
OutputStream outputStream = null;
Socket socket = null;
int length = 0;
byte[] buffer = new byte[1024];
try {
SocksProxy proxy = new Socks5("x.x.x.x", 1080, new
UsernamePasswordCredentials("x", "x"));
socket = new SocksSocket(proxy, new InetSocketAddress(url.getHost(), url.getPort()));
inputStream = socket.getInputStream();
outputStream = socket.getOutputStream();
PrintWriter printWriter = new PrintWriter(outputStream);
printWriter.print("GET " + url + " HTTP/1.1\r\n");
printWriter.print("Host: " + url.getHost() + "\r\n");
printWriter.print("\r\n");
printWriter.flush();
The text was updated successfully, but these errors were encountered: