Search in sources :

Example 96 with Builder

use of okhttp3.OkHttpClient.Builder in project DevRing by LJYcoder.

the class HttpHeaderInterceptor method intercept.

@Override
public Response intercept(Chain chain) throws IOException {
    Request originalRequest = chain.request();
    Request.Builder builder = originalRequest.newBuilder();
    for (Map.Entry<String, String> entry : mMapHeader.entrySet()) {
        builder.header(entry.getKey(), entry.getValue());
    }
    Request.Builder requestBuilder = builder.method(originalRequest.method(), originalRequest.body());
    Request request = requestBuilder.build();
    return chain.proceed(request);
}
Also used : Request(okhttp3.Request) Map(java.util.Map)

Example 97 with Builder

use of okhttp3.OkHttpClient.Builder in project bugzy by cpunq.

the class NetModule method provideFogBugzService.

@Provides
@Singleton
FogbugzApiService provideFogBugzService(Application application, PrefsHelper prefsHelper, Gson gson) {
    OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
    Retrofit.Builder builder = new Retrofit.Builder().baseUrl(mBaseUrl).addCallAdapterFactory(new LiveDataCallAdapterFactory(gson)).addConverterFactory(GsonConverterFactory.create(gson));
    Retrofit retrofit = builder.client(httpClient.addInterceptor(new ConnectivityInterceptor(application.getApplicationContext())).addInterceptor(new RequestInterceptor(prefsHelper)).build()).build();
    return retrofit.create(FogbugzApiService.class);
}
Also used : LiveDataCallAdapterFactory(com.bluestacks.bugzy.utils.LiveDataCallAdapterFactory) Retrofit(retrofit2.Retrofit) OkHttpClient(okhttp3.OkHttpClient) GsonBuilder(com.google.gson.GsonBuilder) RequestInterceptor(com.bluestacks.bugzy.data.remote.RequestInterceptor) ConnectivityInterceptor(com.bluestacks.bugzy.data.remote.ConnectivityInterceptor) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Aggregations

Request (okhttp3.Request)47 Response (okhttp3.Response)44 OkHttpClient (okhttp3.OkHttpClient)31 IOException (java.io.IOException)28 RequestBody (okhttp3.RequestBody)27 Test (org.junit.Test)17 Interceptor (okhttp3.Interceptor)11 File (java.io.File)9 Provides (dagger.Provides)8 X509TrustManager (javax.net.ssl.X509TrustManager)8 Retrofit (retrofit2.Retrofit)8 URI (java.net.URI)7 Map (java.util.Map)7 MultipartBody (okhttp3.MultipartBody)7 Singleton (javax.inject.Singleton)6 HttpUrl (okhttp3.HttpUrl)6 ResponseBody (okhttp3.ResponseBody)6 SSLContext (javax.net.ssl.SSLContext)5 TrustManager (javax.net.ssl.TrustManager)5 TestClients.clientRequest (keywhiz.TestClients.clientRequest)5