Here is my code
import jodd.http.*;
import jodd.http.net.*;
public class JoddQuestion {
public static void main(String[] args) {
SocketHttpConnectionProvider connectionProvider = new SocketHttpConnectionProvider();
ProxyInfo proxyInfo = ProxyInfo.httpProxy("xxxx", xx, "xxxx", "xxxx");
connectionProvider.useProxy(proxyInfo);
String url = "http://www.google.com";
HttpResponse response = HttpRequest.get(url).open(connectionProvider).connectionTimeout(1000).timeout(1000).followRedirects(true).send();
System.out.print(response.bodyText());
}
}
Google website is blocked by firewall in China. Without setting the proxy, run the program, connectionTimeout works.
HttpResponse response = HttpRequest.get(url).connectionTimeout(1000).timeout(1000).followRedirects(true).send();
However, after setting the proxy, connectionTimeout does not work and program just keeps trying.
HttpResponse response = HttpRequest.get(url).open(connectionProvider).connectionTimeout(1000).timeout(1000).followRedirects(true).send();