diff --git a/src/main/java/com/hcl/appscan/sdk/http/HttpClient.java b/src/main/java/com/hcl/appscan/sdk/http/HttpClient.java index 0ba6ed86..45cc99fb 100644 --- a/src/main/java/com/hcl/appscan/sdk/http/HttpClient.java +++ b/src/main/java/com/hcl/appscan/sdk/http/HttpClient.java @@ -1,17 +1,15 @@ /** * © Copyright IBM Corporation 2016. - * © Copyright HCL Technologies Ltd. 2017, 2023. + * © Copyright HCL Technologies Ltd. 2017, 2024. * LICENSE: Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0 */ package com.hcl.appscan.sdk.http; - -import org.apache.wink.json4j.JSON; import org.apache.wink.json4j.JSONObject; - import java.io.DataOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.net.HttpURLConnection; import java.net.Proxy; import java.net.URL; import java.net.URLEncoder; @@ -256,7 +254,7 @@ public HttpResponse postMultipart(String url, private HttpResponse makeMultipartRequest(Method method, String url, Map headerProperties, List parts) throws IOException { - HttpsURLConnection conn = makeConnection(url, method, headerProperties); + HttpURLConnection conn = makeConnection(url, method, headerProperties); DataOutputStream outputStream = null; conn.setChunkedStreamingMode(1024); @@ -312,7 +310,7 @@ private HttpResponse makeMultipartRequest(Method method, String url, private HttpResponse makeRequest(Method method, String url, Map headerProperties, String payload) throws IOException { - HttpsURLConnection conn = makeConnection(url, method, headerProperties); + HttpURLConnection conn = makeConnection(url, method, headerProperties); // Write payload if (payload != null) { @@ -327,15 +325,15 @@ private HttpResponse makeRequest(Method method, String url, return new HttpResponse(conn); } - private HttpsURLConnection makeConnection(String url, Method method, + private HttpURLConnection makeConnection(String url, Method method, Map headerProperties) throws IOException { URL requestURL = new URL(url); - HttpsURLConnection conn = null; - conn = (HttpsURLConnection) requestURL.openConnection(m_proxy); + HttpURLConnection conn = null; + conn = (HttpURLConnection) requestURL.openConnection(m_proxy); conn.setRequestMethod(method.name()); conn.setReadTimeout(0); - if(m_bypassSSL) { - bypassSSL(conn); + if((conn instanceof HttpsURLConnection) && m_bypassSSL) { + bypassSSL((HttpsURLConnection)conn); } // HTTP headers