/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.common.http.GenericHttpClient
 *  com.l7tech.common.http.GenericHttpClientFactory
 *  com.l7tech.common.http.HttpProxyConfig
 *  com.l7tech.common.http.prov.apache.components.ClientConnectionManagerFactory
 *  com.l7tech.common.http.prov.apache.components.ClientConnectionManagerFactory$ConnectionManagerType
 *  com.l7tech.common.http.prov.apache.components.HttpComponentsClient
 *  org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager
 *  org.apache.hc.client5.http.io.HttpClientConnectionManager
 *  org.apache.hc.core5.pool.PoolStats
 */
package com.l7tech.server.util;

import com.l7tech.common.http.GenericHttpClient;
import com.l7tech.common.http.GenericHttpClientFactory;
import com.l7tech.common.http.HttpProxyConfig;
import com.l7tech.common.http.prov.apache.components.ClientConnectionManagerFactory;
import com.l7tech.common.http.prov.apache.components.HttpComponentsClient;
import com.l7tech.server.transport.http.HttpConnectionManagerListener;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
import org.apache.hc.client5.http.io.HttpClientConnectionManager;
import org.apache.hc.core5.pool.PoolStats;

public class IdentityBindingHttpClientFactory
implements GenericHttpClientFactory {
    private HttpClientConnectionManager a;
    private HttpConnectionManagerListener b = new HttpConnectionManagerListener.HttpConnectionManagerListenerAdapter();
    private boolean c;

    public GenericHttpClient createHttpClient() {
        return this.createHttpClient(-1, -1, -1, -1, -1, null, null);
    }

    public GenericHttpClient createHttpClient(int n2, int n3, int n4, int n5, int n6, Object object, HttpProxyConfig httpProxyConfig) {
        return new HttpComponentsClient(this.a(n2, n3), object, n4, n5, n6, httpProxyConfig);
    }

    public void setListener(HttpConnectionManagerListener httpConnectionManagerListener) {
        this.b = httpConnectionManagerListener == null ? new HttpConnectionManagerListener.HttpConnectionManagerListenerAdapter() : httpConnectionManagerListener;
    }

    public void setUseHttp10(boolean bl2) {
        this.c = bl2;
    }

    private HttpClientConnectionManager a(int n2, int n3) {
        if (this.a == null) {
            if (n2 <= 0) {
                n2 = HttpComponentsClient.getDefaultMaxConnectionsPerHost();
                n3 = HttpComponentsClient.getDefaultMaxTotalConnections();
            }
            ClientConnectionManagerFactory clientConnectionManagerFactory = ClientConnectionManagerFactory.getInstance();
            this.a = clientConnectionManagerFactory.createConnectionManager(ClientConnectionManagerFactory.ConnectionManagerType.IDENTITY_BINDING, n2, n3, this.c);
            this.b.notifyHttpConnectionManagerCreated(this.a);
        }
        return this.a;
    }

    protected PoolStats getTotalStats() {
        if (this.a == null) {
            return null;
        }
        return ((PoolingHttpClientConnectionManager)this.a).getTotalStats();
    }
}

