@SuppressWarnings("deprecation")
    private final HttpResponse executeHttpRequest(HttpGet getMethod, String host) throws Exception {
        SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, new TrustStrategy() {

            @Override
            public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
                return true;
            }
        }).build();
        SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext,
            new String[] { "TLSv1" },
            null,
            SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
        Registry registry = RegistryBuilder.create()
            .register("http", PlainConnectionSocketFactory.INSTANCE)
            .register("https", sslsf)
            .build();
        HttpClientConnectionManager httpClientConnectionManager = new PoolingHttpClientConnectionManager(registry);
        CloseableHttpClient httpClient = HttpClientBuilder.create()
            .setMaxConnPerRoute(50)
            .setMaxConnTotal(100)
            .setConnectionManager(httpClientConnectionManager)
            .build();
        RequestConfig requestConfig = RequestConfig.custom()
            .setConnectTimeout(timeout)
            .setConnectionRequestTimeout(timeout)
            .setSocketTimeout(timeout)
            .build();
        getMethod.setConfig(requestConfig);
        HttpResponse response = httpClient.execute(getMethod);
        int statusCode = response.getStatusLine().getStatusCode();
        if (statusCode != HttpResponseStatus.OK.code() && statusCode != HttpResponseStatus.PARTIAL_CONTENT.code()) {
            String result = EntityUtils.toString(response.getEntity());
            throw new RuntimeException("return error !" + response.getStatusLine().getReasonPhrase() + ", " + result);
        }
        return response;
    }
@ SuppressWarnings ( "deprecation" ) private final HttpResponse executeHttpRequest ( HttpGet getMethod , String host ) throws Exception { SSLContext sslContext = SSLContexts . custom ( ) . loadTrustMaterial ( null , new TrustStrategy ( ) { @ Override public boolean isTrusted ( X509Certificate [ ] arg0 , String arg1 ) throws CertificateException { return true ; } } ) . build ( ) ; SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory ( sslContext , new String [ ] { "TLSv1" } , null , SSLConnectionSocketFactory . ALLOW_ALL_HOSTNAME_VERIFIER ) ; Registry registry = RegistryBuilder . create ( ) . register ( "http" , PlainConnectionSocketFactory . INSTANCE ) . register ( "https" , sslsf ) . build ( ) ; HttpClientConnectionManager httpClientConnectionManager = new PoolingHttpClientConnectionManager ( registry ) ; CloseableHttpClient httpClient = HttpClientBuilder . create ( ) . setMaxConnPerRoute ( 50 ) . setMaxConnTotal ( 100 ) . setConnectionManager ( httpClientConnectionManager ) . build ( ) ; RequestConfig requestConfig = RequestConfig . custom ( ) . setConnectTimeout ( timeout ) . setConnectionRequestTimeout ( timeout ) . setSocketTimeout ( timeout ) . build ( ) ; getMethod . setConfig ( requestConfig ) ; HttpResponse response = httpClient . execute ( getMethod ) ; int statusCode = response . getStatusLine ( ) . getStatusCode ( ) ; if ( statusCode != HttpResponseStatus . OK . code ( ) && statusCode != HttpResponseStatus . PARTIAL_CONTENT . code ( ) ) { String result = EntityUtils . toString ( response . getEntity ( ) ) ; throw new RuntimeException ( "return error !" + response . getStatusLine ( ) . getReasonPhrase ( ) + ", " + result ) ; } return response ; }
执行http请求

@param getMethod
@return
@throws IOException