Fix debug curl commands for included data

Include the submitted data in the curl debug statement.
Initially fixed in: https://review.openstack.org/#/c/53501

Change-Id: I4e3e9e4799a508666fb37fafe864eea25b676836
Closes-Bug: #1249891
This commit is contained in:
Jamie Lennox
2014-02-03 11:12:00 +10:00
committed by Gerrit Code Review
parent d4edb09639
commit 06e3420dca
2 changed files with 8 additions and 5 deletions

View File

@@ -165,11 +165,12 @@ class Session(object):
for header in six.iteritems(headers):
string_parts.append('-H "%s: %s"' % header)
_logger.debug('REQ: %s', ' '.join(string_parts))
try:
string_parts.append("-d '%s'" % kwargs['data'])
except KeyError:
pass
data = kwargs.get('data')
if data:
_logger.debug('REQ BODY: %s', data)
_logger.debug('REQ: %s', ' '.join(string_parts))
# Force disable requests redirect handling. We will manage this below.
kwargs['allow_redirects'] = False

View File

@@ -146,13 +146,15 @@ class SessionTests(utils.TestCase):
session = client_session.Session(verify=False)
headers = {'HEADERA': 'HEADERVALB'}
body = 'BODYRESPONSE'
data = 'BODYDATA'
self.stub_url(httpretty.POST, body=body)
session.post(self.TEST_URL, headers=headers)
session.post(self.TEST_URL, headers=headers, data=data)
self.assertIn('curl', self.logger.output)
self.assertIn('POST', self.logger.output)
self.assertIn('--insecure', self.logger.output)
self.assertIn(body, self.logger.output)
self.assertIn("'%s'" % data, self.logger.output)
for k, v in six.iteritems(headers):
self.assertIn(k, self.logger.output)