Merge "Do not log binary data during request"
This commit is contained in:
@@ -203,6 +203,11 @@ class Session(object):
|
|||||||
% self._process_header(header))
|
% self._process_header(header))
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
|
if isinstance(data, six.binary_type):
|
||||||
|
try:
|
||||||
|
data = data.decode("ascii")
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
data = "<binary_data>"
|
||||||
string_parts.append("-d '%s'" % data)
|
string_parts.append("-d '%s'" % data)
|
||||||
try:
|
try:
|
||||||
logger.debug(' '.join(string_parts))
|
logger.debug(' '.join(string_parts))
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
# 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
|
# not use this file except in compliance with the License. You may obtain
|
||||||
# a copy of the License at
|
# a copy of the License at
|
||||||
@@ -239,7 +241,7 @@ class SessionTests(utils.TestCase):
|
|||||||
session = client_session.Session(verify=False)
|
session = client_session.Session(verify=False)
|
||||||
|
|
||||||
body = 'RESP'
|
body = 'RESP'
|
||||||
data = u'unicode_data'
|
data = u'αβγδ'
|
||||||
self.stub_url('POST', text=body)
|
self.stub_url('POST', text=body)
|
||||||
session.post(self.TEST_URL, data=data)
|
session.post(self.TEST_URL, data=data)
|
||||||
|
|
||||||
@@ -264,12 +266,7 @@ class SessionTests(utils.TestCase):
|
|||||||
# raise a UnicodeDecodeError)
|
# raise a UnicodeDecodeError)
|
||||||
session.post(unicode(self.TEST_URL), data=data)
|
session.post(unicode(self.TEST_URL), data=data)
|
||||||
|
|
||||||
self.assertIn("Replaced characters that could not be decoded"
|
self.assertNotIn('my data', self.logger.output)
|
||||||
" in log output", self.logger.output)
|
|
||||||
|
|
||||||
# Our data payload should have changed to
|
|
||||||
# include the replacement char
|
|
||||||
self.assertIn(u"-d 'my data\ufffd'", self.logger.output)
|
|
||||||
|
|
||||||
def test_logging_cacerts(self):
|
def test_logging_cacerts(self):
|
||||||
path_to_certs = '/path/to/certs'
|
path_to_certs = '/path/to/certs'
|
||||||
|
Reference in New Issue
Block a user