All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.ably.lib.network.OkHttpEngine Maven / Gradle / Ivy

There is a newer version: 1.2.48
Show newest version
package io.ably.lib.network;

import okhttp3.Call;
import okhttp3.OkHttpClient;

import java.util.concurrent.TimeUnit;

public class OkHttpEngine implements HttpEngine {

    private final OkHttpClient client;
    private final HttpEngineConfig config;

    public OkHttpEngine(OkHttpClient client, HttpEngineConfig config) {
        this.client = client;
        this.config = config;
    }

    @Override
    public HttpCall call(HttpRequest request) {
        Call call = client.newBuilder()
            .connectTimeout(request.getHttpOpenTimeout(), TimeUnit.MILLISECONDS)
            .readTimeout(request.getHttpReadTimeout(), TimeUnit.MILLISECONDS)
            .build()
            .newCall(OkHttpUtils.toOkhttpRequest(request));
        return new OkHttpCall(call);
    }

    @Override
    public boolean isUsingProxy() {
        return config.getProxy() != null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy