Search in sources :

Example 1 with Request

use of com.kymjs.rxvolley.http.Request in project yoo_home_Android by culturer.

the class OkHttpStack method performRequest.

@Override
public URLHttpResponse performRequest(Request<?> request, ArrayList<HttpParamsEntry> additionalHeaders) throws IOException {
    OkHttpClient client = mClient.clone();
    int timeoutMs = request.getTimeoutMs();
    client.setConnectTimeout(timeoutMs, TimeUnit.MILLISECONDS);
    client.setReadTimeout(timeoutMs, TimeUnit.MILLISECONDS);
    client.setWriteTimeout(timeoutMs, TimeUnit.MILLISECONDS);
    com.squareup.okhttp.Request.Builder okHttpRequestBuilder = new com.squareup.okhttp.Request.Builder();
    okHttpRequestBuilder.url(request.getUrl());
    for (final HttpParamsEntry entry : request.getHeaders()) {
        okHttpRequestBuilder.addHeader(entry.k, entry.v);
    }
    for (final HttpParamsEntry entry : additionalHeaders) {
        okHttpRequestBuilder.addHeader(entry.k, entry.v);
    }
    setConnectionParametersForRequest(okHttpRequestBuilder, request);
    com.squareup.okhttp.Request okHttpRequest = okHttpRequestBuilder.build();
    Call okHttpCall = client.newCall(okHttpRequest);
    Response okHttpResponse = okHttpCall.execute();
    return responseFromConnection(okHttpResponse);
}
Also used : Response(com.squareup.okhttp.Response) URLHttpResponse(com.kymjs.rxvolley.http.URLHttpResponse) Call(com.squareup.okhttp.Call) OkHttpClient(com.squareup.okhttp.OkHttpClient) Request(com.kymjs.rxvolley.http.Request) HttpParamsEntry(com.kymjs.rxvolley.toolbox.HttpParamsEntry)

Example 2 with Request

use of com.kymjs.rxvolley.http.Request in project yoo_home_Android by culturer.

the class OkHttpStack method performRequest.

@Override
public URLHttpResponse performRequest(Request<?> request, ArrayList<HttpParamsEntry> additionalHeaders) throws IOException {
    int timeoutMs = request.getTimeoutMs();
    OkHttpClient client = mClient.newBuilder().readTimeout(timeoutMs, TimeUnit.MILLISECONDS).connectTimeout(timeoutMs, TimeUnit.MILLISECONDS).writeTimeout(timeoutMs, TimeUnit.MILLISECONDS).build();
    okhttp3.Request.Builder okHttpRequestBuilder = new okhttp3.Request.Builder();
    okHttpRequestBuilder.url(request.getUrl());
    for (final HttpParamsEntry entry : request.getHeaders()) {
        okHttpRequestBuilder.addHeader(entry.k, entry.v);
    }
    for (final HttpParamsEntry entry : additionalHeaders) {
        okHttpRequestBuilder.addHeader(entry.k, entry.v);
    }
    setConnectionParametersForRequest(okHttpRequestBuilder, request);
    okhttp3.Request okHttpRequest = okHttpRequestBuilder.build();
    Call okHttpCall = client.newCall(okHttpRequest);
    Response okHttpResponse = okHttpCall.execute();
    return responseFromConnection(okHttpResponse);
}
Also used : Response(okhttp3.Response) URLHttpResponse(com.kymjs.rxvolley.http.URLHttpResponse) Call(okhttp3.Call) OkHttpClient(okhttp3.OkHttpClient) Request(com.kymjs.rxvolley.http.Request) HttpParamsEntry(com.kymjs.rxvolley.toolbox.HttpParamsEntry)

Aggregations

Request (com.kymjs.rxvolley.http.Request)2 URLHttpResponse (com.kymjs.rxvolley.http.URLHttpResponse)2 HttpParamsEntry (com.kymjs.rxvolley.toolbox.HttpParamsEntry)2 Call (com.squareup.okhttp.Call)1 OkHttpClient (com.squareup.okhttp.OkHttpClient)1 Response (com.squareup.okhttp.Response)1 Call (okhttp3.Call)1 OkHttpClient (okhttp3.OkHttpClient)1 Response (okhttp3.Response)1