Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.opensearch.javasdk.util;
 
 import java.util.Map;
 
 
 public class HttpClientManager {
    private static HttpClientFactory httpClientFactory = new HttpClientFactory(0, 0, 0);
        return .;
    }
    //设置连接池最大连接数
    public static void setMaxConnections(int maxConnections){
        if (maxConnections > 0 && maxConnections != .getMaxConnections()) {
            if( != null){
                .shutdownIdleConnectionMonitor();
            }
             = new HttpClientFactory(0, 0, maxConnections);
        }
    }
    //设置超时时间
    public static void setTimeout(int timeout) {
        .setTimeOut(timeout);
    }
    public static void setGzip() {
        .setGzip();
    }
    //设置连接超时时间
    public static void setConnectTimeout(int connectTimeout) {
        .setConnectTimeout(connectTimeout);
    }
    public static String doPost(String requestPathMap<StringStringparamsString encoding)
                    throws ClientProtocolExceptionIOException {
        return .doPost(requestPathparamsencoding);
    }
    public static String doGet(String urlString encodingboolean isPBthrows ClientProtocolExceptionIOException {
        return .doGet(urlencodingisPB);
    }
New to GrepCode? Check out our FAQ X