Created
June 2, 2016 22:38
-
-
Save bexp/90d788ed58055d750a9f590502b8960c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private final OkHttpClient client; | |
public ConfigureTimeouts() throws Exception { | |
client = new OkHttpClient.Builder() | |
.connectTimeout(10, TimeUnit.SECONDS) | |
.writeTimeout(10, TimeUnit.SECONDS) | |
.readTimeout(30, TimeUnit.SECONDS) | |
.build(); | |
} | |
public void run() throws Exception { | |
Request request = new Request.Builder() | |
.url("http://httpbin.org/delay/2") // This URL is served with a 2 second delay. | |
.build(); | |
Response response = client.newCall(request).execute(); | |
System.out.println("Response completed: " + response); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment