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

de.mediathekview.mlib.tool.MVHttpClient Maven / Gradle / Ivy

Go to download

A central library with tools and utils for the MediathekView Client and the MediathekView Server

The newest version!
package de.mediathekview.mlib.tool;

import java.util.concurrent.TimeUnit;

import okhttp3.ConnectionPool;
import okhttp3.OkHttpClient;

public class MVHttpClient {
    private final static MVHttpClient ourInstance = new MVHttpClient();
    private final OkHttpClient httpClient;
    private final OkHttpClient copyClient;

    private MVHttpClient() {
        httpClient = new OkHttpClient.Builder()
                .connectTimeout(30, TimeUnit.SECONDS)
                .writeTimeout(30, TimeUnit.SECONDS)
                .readTimeout(30, TimeUnit.SECONDS)
                .connectionPool(new ConnectionPool(100, 1, TimeUnit.SECONDS))
                .build();
        httpClient.dispatcher().setMaxRequests(100);

        copyClient = httpClient.newBuilder()
                .connectTimeout(5, TimeUnit.SECONDS)
                .readTimeout(5, TimeUnit.SECONDS)
                .writeTimeout(2, TimeUnit.SECONDS).build();
    }

    public static MVHttpClient getInstance() {
        return ourInstance;
    }

    public OkHttpClient getHttpClient() {
        return httpClient;
    }

    public OkHttpClient getReducedTimeOutClient() {
        return copyClient;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy