@@ -15,7 +15,6 @@ public class HttpClientHandler {
1515 private final HttpClient httpClient ;
1616 protected final DataHandler dataHandler ;
1717 private final HttpClientErrorHandler httpClientErrorHandler ;
18- private boolean secureConnection = true ;
1918
2019 protected HttpClientHandler (MultivaluedMap <String ,Object > headers ) {
2120 this .dataHandler = new DataHandler (false );
@@ -25,7 +24,7 @@ protected HttpClientHandler(MultivaluedMap<String,Object> headers) {
2524
2625 protected HttpClientHandler (MultivaluedMap <String ,Object > headers , boolean secureConnection ) {
2726 this (headers );
28- this .secureConnection = secureConnection ;
27+ this .getHttpClient (). setSecureConnection ( secureConnection ) ;
2928 }
3029
3130 /**
@@ -59,7 +58,7 @@ protected String execute(HttpClient.REQUEST_TYPES request_type, String url) thro
5958 * @return HTTP response message
6059 */
6160 protected String execute (HttpClient .REQUEST_TYPES request_type , String url , Object data ) throws PostmarkException , IOException {
62- HttpClient .ClientResponse response = httpClient .execute (request_type , getSecureUrl ( url ) , dataHandler .toJson (data ));
61+ HttpClient .ClientResponse response = httpClient .execute (request_type , url , dataHandler .toJson (data ));
6362
6463 if (response .getCode () == 200 ) {
6564 return response .getMessage ();
@@ -77,10 +76,6 @@ public void setDebugMode() {
7776 this .dataHandler .setStrictMapper ();
7877 }
7978
80- public void setSecureConnection (boolean secureConnection ) {
81- this .secureConnection = secureConnection ;
82- }
83-
8479 /**
8580 * @return HTTP client which processes HTTP requests
8681 */
@@ -89,7 +84,7 @@ public HttpClient getHttpClient() {
8984 }
9085
9186 /**
92- * Delegation method for HTTP client connection setttings
87+ * Delegation method for HTTP client connection settings
9388 *
9489 * @param connectTimeoutSeconds HTTP client connection timeout
9590 */
@@ -98,21 +93,25 @@ public void setConnectTimeoutSeconds(int connectTimeoutSeconds) {
9893 }
9994
10095 /**
101- * Delegation method for HTTP client connection setttings
96+ * Delegation method for HTTP client connection settings
10297 *
10398 * @param readTimeoutSeconds HTTP client read timeout
10499 */
105100 public void setReadTimeoutSeconds (int readTimeoutSeconds ) {
106101 getHttpClient ().setReadTimeoutSeconds (readTimeoutSeconds );
107102 }
108103
104+ /**
105+ * Delegation method for HTTP client connection settings
106+ *
107+ * @param secureConnection - choose http or https
108+ */
109+ public void setSecureConnection (boolean secureConnection ) {
110+ getHttpClient ().setSecureConnection (secureConnection );
111+ }
112+
109113 /**
110114 * @return DataHandler which processes HTTP requests sent, and HTTP request responses
111115 */
112116 public DataHandler getDataHandler () { return dataHandler ; }
113-
114- private String getSecureUrl (String url ) {
115- String urlPrefix = this .secureConnection ? "https://" : "http://" ;
116- return urlPrefix + url ;
117- }
118117}
0 commit comments