Michael Pasternak has uploaded a new change for review.

Change subject: sdk: add print of the whole response body in debug mode #887808
......................................................................

sdk: add print of the whole response body in debug mode #887808

https://bugzilla.redhat.com/show_bug.cgi?id=887808

Change-Id: I3b2b3d56d0ffdd78471e4a9088b23d9e2cedf3cb
Signed-off-by: Michael Pasternak <[email protected]>
---
M src/ovirtsdk/infrastructure/proxy.py
1 file changed, 9 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine-sdk refs/changes/33/10433/1

diff --git a/src/ovirtsdk/infrastructure/proxy.py 
b/src/ovirtsdk/infrastructure/proxy.py
index 83122a9..df2e080 100644
--- a/src/ovirtsdk/infrastructure/proxy.py
+++ b/src/ovirtsdk/infrastructure/proxy.py
@@ -144,6 +144,7 @@
 
             # Send the request and wait for the response:
             conn.doRequest(method=method, url=url, body=body, headers=headers)
+
             response = conn.getResponse()
 
             # Read the response headers (there is always a response,
@@ -163,6 +164,10 @@
 
             # Parse the body:
             response_body = response.read()
+
+            # Print response body (if in debug mode)
+            self.__do_debug(conn, response_body)
+
             return params.parseString(response_body) if response_body is not 
None and response_body is not '' \
                                                      else response_body
         except socket.error, e:
@@ -170,6 +175,10 @@
         finally:
             conn.close()
 
+    def __do_debug(self, conn, body):
+        if conn.getConnection().debuglevel:
+                print 'body:\n' + body if body else ''
+
     def get_url(self):
         return self.getConnectionsPool().get_url()
 


--
To view, visit http://gerrit.ovirt.org/10433
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3b2b3d56d0ffdd78471e4a9088b23d9e2cedf3cb
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine-sdk
Gerrit-Branch: master
Gerrit-Owner: Michael Pasternak <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to