Added debug messages to http req/res method, improved debug output
Change-Id: Id00a89ed93f7b7c6e9dbd4914ab656ae7895e1cf
diff --git a/src/com/mirantis/mk/Http.groovy b/src/com/mirantis/mk/Http.groovy
index d7d6f35..704d0cb 100644
--- a/src/com/mirantis/mk/Http.groovy
+++ b/src/com/mirantis/mk/Http.groovy
@@ -13,9 +13,8 @@
* @param data JSON data to POST or PUT
* @param headers Map of additional request headers
*/
-@NonCPS
def sendHttpRequest(url, method = 'GET', data = null, headers = [:]) {
-
+ def common = new com.mk.mirantis.Common()
def connection = new URL(url).openConnection()
if (method != 'GET') {
connection.setRequestMethod(method)
@@ -40,7 +39,7 @@
dataStr = new groovy.json.JsonBuilder(data).toString()
}
def output = new OutputStreamWriter(connection.outputStream)
- //infoMsg("[HTTP] Request URL: ${url}, method: ${method}, headers: ${headers}, content: ${dataStr}")
+ common.debugMsg("[HTTP] Request URL: ${url}, method: ${method}, headers: ${headers}, content: ${dataStr}")
output.write(dataStr)
output.close()
}
@@ -52,10 +51,10 @@
} catch (groovy.json.JsonException e) {
response_content = response
}
- //successMsg("[HTTP] Response: code ${connection.responseCode}")
+ common.debugMsg("[HTTP] Response: code ${connection.responseCode}")
return response_content
} else {
- //errorMsg("[HTTP] Response: code ${connection.responseCode}")
+ common.debugMsg("[HTTP] Response: code ${connection.responseCode}")
throw new Exception(connection.responseCode + ": " + connection.inputStream.text)
}