Last active
March 28, 2017 09:08
-
-
Save ogregoire/98db7d5eefdeb83604bb622747b23b61 to your computer and use it in GitHub Desktop.
OkHttpExample
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
OkHttpClient client = new OkHttpClient.Builder() | |
// Logging | |
.addInterceptor(new HttpLoggingInterceptor(System.err::println).setLevel(HttpLoggingInterceptor.Level.BODY)) | |
// Timeout | |
.connectTimeout(60, TimeUnit.SECONDS) | |
.writeTimeout(60, TimeUnit.SECONDS) | |
.readTimeout(60, TimeUnit.SECONDS) | |
// Proxy | |
.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort)) | |
.proxyAuthenticator(($, response) -> response.request().newBuilder() | |
.header("Proxy-Authorization", Credentials.basic(proxyUser, proxyPassword)) | |
.build()) | |
.build(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment