diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
index 63caf5a..e2a4c2f 100644
--- a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
+++ b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
@@ -36,6 +36,7 @@
 import org.onap.clamp.clds.config.ClampProperties;
 import org.onap.clamp.clds.exception.dcae.DcaeDeploymentException;
 import org.onap.clamp.clds.util.LoggingUtils;
+import org.onap.clamp.util.HttpConnectionManager;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -49,7 +50,7 @@
     protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeDispatcherServices.class);
     protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
     private final ClampProperties refProp;
-    private final DcaeHttpConnectionManager dcaeHttpConnectionManager;
+    private final HttpConnectionManager dcaeHttpConnectionManager;
     private static final String STATUS_URL_LOG = "Status URL extracted: ";
     private static final String DCAE_URL_PREFIX = "/dcae-deployments/";
     private static final String DCAE_URL_PROPERTY_NAME = "dcae.dispatcher.url";
@@ -58,7 +59,7 @@
     private static final String DCAE_STATUS_FIELD = "status";
 
     @Autowired
-    public DcaeDispatcherServices(ClampProperties refProp, DcaeHttpConnectionManager dcaeHttpConnectionManager) {
+    public DcaeDispatcherServices(ClampProperties refProp, HttpConnectionManager dcaeHttpConnectionManager) {
         this.refProp = refProp;
         this.dcaeHttpConnectionManager = dcaeHttpConnectionManager;
     }
@@ -98,7 +99,7 @@
         Date startTime = new Date();
         LoggingUtils.setTargetContext("DCAE", "getOperationStatus");
         try {
-            String responseStr = dcaeHttpConnectionManager.doDcaeHttpQuery(statusUrl, "GET", null, null);
+            String responseStr = dcaeHttpConnectionManager.doGeneralHttpQuery(statusUrl, "GET", null, null, "DCAE");
             JSONObject jsonObj = parseResponse(responseStr);
             String operationType = (String) jsonObj.get("operationType");
             String status = (String) jsonObj.get(DCAE_STATUS_FIELD);
@@ -189,7 +190,7 @@
         String nodeAttr) throws IOException, ParseException {
         Date startTime = new Date();
         try {
-            String responseStr = dcaeHttpConnectionManager.doDcaeHttpQuery(url, requestMethod, payload, contentType);
+            String responseStr = dcaeHttpConnectionManager.doGeneralHttpQuery(url, requestMethod, payload, contentType, "DCAE");
             JSONObject jsonObj = parseResponse(responseStr);
             JSONObject linksObj = (JSONObject) jsonObj.get(node);
             String statusUrl = (String) linksObj.get(nodeAttr);
diff --git a/src/main/java/org/onap/clamp/util/HttpConnectionManager.java b/src/main/java/org/onap/clamp/util/HttpConnectionManager.java
new file mode 100644
index 0000000..9443301
--- /dev/null
+++ b/src/main/java/org/onap/clamp/util/HttpConnectionManager.java
@@ -0,0 +1,146 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ *                             reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * Modifications copyright (c) 2018 Nokia
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.util;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.ws.rs.BadRequestException;
+
+import org.apache.commons.io.IOUtils;
+import org.onap.clamp.clds.util.LoggingUtils;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class manages the HTTP and HTTPS connections.
+ */
+@Component
+public class HttpConnectionManager {
+    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(HttpConnectionManager.class);
+    protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
+    private static final String REQUEST_FAILED_LOG = "Request Failed - response payload=";
+
+    private String doHttpsQuery(URL url, String requestMethod, String payload, String contentType, String target) throws IOException {
+        LoggingUtils utils = new LoggingUtils(logger);
+        logger.info("Using HTTPS URL:" + url.toString());
+        HttpsURLConnection secureConnection = (HttpsURLConnection) url.openConnection();
+        secureConnection = utils.invokeHttps(secureConnection, target, requestMethod);
+        secureConnection.setRequestMethod(requestMethod);
+        secureConnection.setRequestProperty("X-ECOMP-RequestID", LoggingUtils.getRequestId());
+        if (payload != null && contentType != null) {
+            secureConnection.setRequestProperty("Content-Type", contentType);
+            secureConnection.setDoOutput(true);
+            try (DataOutputStream wr = new DataOutputStream(secureConnection.getOutputStream())) {
+                wr.writeBytes(payload);
+                wr.flush();
+            }
+        }
+        int responseCode = secureConnection.getResponseCode();
+        logger.info("Response Code: " + responseCode);
+        if (responseCode < 400) {
+            try (BufferedReader reader = new BufferedReader(new InputStreamReader(secureConnection.getInputStream()))) {
+                String responseStr = IOUtils.toString(reader);
+                logger.info("Response Content: " + responseStr);
+                return responseStr;
+            }
+        } else {
+            // In case of connection failure just check whether there is a
+            // content or not
+            try (BufferedReader reader = new BufferedReader(new InputStreamReader(secureConnection.getErrorStream()))) {
+                String responseStr = IOUtils.toString(reader);
+                logger.error(REQUEST_FAILED_LOG + responseStr);
+                throw new BadRequestException(responseStr);
+            }
+        }
+    }
+
+    private String doHttpQuery(URL url, String requestMethod, String payload, String contentType, String target) throws IOException {
+        LoggingUtils utils = new LoggingUtils(logger);
+        logger.info("Using HTTP URL:" + url);
+        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+        connection = utils.invoke(connection, target, requestMethod);
+        connection.setRequestMethod(requestMethod);
+        if (payload != null && contentType != null) {
+            connection.setRequestProperty("Content-Type", contentType);
+            connection.setDoOutput(true);
+            try (DataOutputStream wr = new DataOutputStream(connection.getOutputStream())) {
+                wr.writeBytes(payload);
+                wr.flush();
+            }
+        }
+        int responseCode = connection.getResponseCode();
+        logger.info("Response Code: " + responseCode);
+        if (responseCode < 400) {
+            try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
+                String responseStr = IOUtils.toString(reader);
+                logger.info("Response Content: " + responseStr);
+                utils.invokeReturn();
+                return responseStr;
+            }
+        } else {
+            // In case of connection failure just check whether there is a
+            // content or not
+            try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getErrorStream()))) {
+                String responseStr = IOUtils.toString(reader);
+                logger.error(REQUEST_FAILED_LOG + responseStr);
+                utils.invokeReturn();
+                throw new BadRequestException(responseStr);
+            }
+        }
+    }
+
+    /**
+     * This method does a HTTP/HTTPS query with parameters specified.
+     *
+     * @param url
+     *        The string HTTP or HTTPS that mustr be used to connect
+     * @param requestMethod
+     *        The Request Method (PUT, POST, GET, DELETE, etc ...)
+     * @param payload
+     *        The payload if any, in that case an ouputstream is opened
+     * @param contentType
+     *        The "application/json or application/xml, or whatever"
+     * @return The payload of the answer
+     * @throws IOException
+     *         In case of issue with the streams
+     */
+    public String doGeneralHttpQuery(String url, String requestMethod, String payload, String contentType, String target)
+        throws IOException {
+        URL urlObj = new URL(url);
+        if (url.contains("https://")) { // Support for HTTPS
+            return doHttpsQuery(urlObj, requestMethod, payload, contentType, target);
+        } else { // Support for HTTP
+            return doHttpQuery(urlObj, requestMethod, payload, contentType, target);
+        }
+    }
+}
