@@ -47,12 +47,27 @@ public CloseableHttpClient getHttpClient() throws FileNotFoundException, IOExcep
4747 {
4848 CloseableHttpClient httpclient = null ;
4949
50+ Header contentHeader = new BasicHeader ( HttpHeaders .CONTENT_TYPE , this .contentType == null ? "application/xml" : this .contentType );
51+ Header acceptHeader = new BasicHeader ( HttpHeaders .ACCEPT , this .accept != null ? this .accept : config .getAccept ());
52+ Header userAgentHeader = new BasicHeader ( HttpHeaders .USER_AGENT , config .getUserAgent ());
53+
54+ List <Header > headers = new ArrayList <Header >();
55+ headers .add (contentHeader );
56+ headers .add (acceptHeader );
57+ headers .add (userAgentHeader );
58+
59+ if (this .ifModifiedSince != null ) {
60+ Header modifiedHeader = new BasicHeader ( HttpHeaders .IF_MODIFIED_SINCE , this .ifModifiedSince );
61+ headers .add (modifiedHeader );
62+ }
63+
64+
5065 if ((config .getKeyStorePath () == null || config .getKeyStorePath ().length () == 0 ) && (config .getKeyStorePassword () == null || config .getKeyStorePassword ().length () == 0 ))
5166 {
5267 if (logger .isInfoEnabled ()){
5368 logger .info ("You must use Java 1.8 to skip setting the Key Store Path & Key Store Password in config.json" );
5469 }
55- httpclient = HttpClients .createDefault ();
70+ httpclient = HttpClients .custom (). setDefaultHeaders ( headers ). build ();
5671
5772 } else {
5873 if (logger .isInfoEnabled ()){
@@ -107,20 +122,6 @@ public CloseableHttpClient getHttpClient() throws FileNotFoundException, IOExcep
107122 new String [] {"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" ,"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" ,"TLS_RSA_WITH_AES_128_CBC_SHA256" ,"TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256" ,"TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256" ,"TLS_DHE_RSA_WITH_AES_128_CBC_SHA256" ,"TLS_DHE_DSS_WITH_AES_128_CBC_SHA256" ,"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA" ,"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" ,"TLS_RSA_WITH_AES_128_CBC_SHA" ,"TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA" ,"TLS_ECDH_RSA_WITH_AES_128_CBC_SHA" ,"TLS_DHE_RSA_WITH_AES_128_CBC_SHA" ,"TLS_DHE_DSS_WITH_AES_128_CBC_SHA" ,"TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA" ,"TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA" ,"TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA" ,"TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA" ,"TLS_EMPTY_RENEGOTIATION_INFO_SCSV" },
108123 SSLConnectionSocketFactory .getDefaultHostnameVerifier ());
109124
110- Header contentHeader = new BasicHeader ( HttpHeaders .CONTENT_TYPE , this .contentType == null ? "application/xml" : this .contentType );
111- Header acceptHeader = new BasicHeader ( HttpHeaders .ACCEPT , this .accept != null ? this .accept : config .getAccept ());
112- Header userAgentHeader = new BasicHeader ( HttpHeaders .USER_AGENT , config .getUserAgent ());
113-
114- List <Header > headers = new ArrayList <Header >();
115- headers .add (contentHeader );
116- headers .add (acceptHeader );
117- headers .add (userAgentHeader );
118-
119- if (this .ifModifiedSince != null ) {
120- Header modifiedHeader = new BasicHeader ( HttpHeaders .IF_MODIFIED_SINCE , this .ifModifiedSince );
121- headers .add (modifiedHeader );
122- }
123-
124125 httpclient = HttpClients .custom ()
125126 .setSSLSocketFactory (sslsf )
126127 .setDefaultHeaders (headers )
0 commit comments