okhttp
okhttp copied to clipboard
IP request with https
if i run the example, it works.
public class GetExample {
OkHttpClient client = new OkHttpClient();
String run(String url) throws IOException {
Request request = new Request.Builder()
.url(url)
.build();
try (Response response = client.newCall(request).execute()) {
return response.body().string();
}
}
public static void main(String[] args) throws IOException {
GetExample example = new GetExample();
String response = example.run("https://github.com/square/okhttp");
System.out.println(response);
}
}
however, if i replace the domain to IP address, problem occurs.
String response = example.run("https://192.30.253.112:443/square/okhttp");
I suffered the same problem with HttpUrlConnection whose bottom implement is OkHttp.
https://stackoverflow.com/questions/40926773/httpsurlconnection-with-ip-issue