Merge "Ignore NoneType when encoding headers"
This commit is contained in:
@@ -147,7 +147,7 @@ class HTTPClient(object):
|
|||||||
names and values
|
names and values
|
||||||
"""
|
"""
|
||||||
return dict((encodeutils.safe_encode(h), encodeutils.safe_encode(v))
|
return dict((encodeutils.safe_encode(h), encodeutils.safe_encode(v))
|
||||||
for h, v in six.iteritems(headers))
|
for h, v in six.iteritems(headers) if v is not None)
|
||||||
|
|
||||||
def _request(self, method, url, **kwargs):
|
def _request(self, method, url, **kwargs):
|
||||||
"""Send an http request with the specified characteristics.
|
"""Send an http request with the specified characteristics.
|
||||||
|
@@ -163,9 +163,10 @@ class TestClient(testtools.TestCase):
|
|||||||
|
|
||||||
def test_headers_encoding(self):
|
def test_headers_encoding(self):
|
||||||
value = u'ni\xf1o'
|
value = u'ni\xf1o'
|
||||||
headers = {"test": value}
|
headers = {"test": value, "none-val": None}
|
||||||
encoded = self.client.encode_headers(headers)
|
encoded = self.client.encode_headers(headers)
|
||||||
self.assertEqual(b"ni\xc3\xb1o", encoded[b"test"])
|
self.assertEqual(b"ni\xc3\xb1o", encoded[b"test"])
|
||||||
|
self.assertNotIn("none-val", encoded)
|
||||||
|
|
||||||
def test_raw_request(self):
|
def test_raw_request(self):
|
||||||
" Verify the path being used for HTTP requests reflects accurately. "
|
" Verify the path being used for HTTP requests reflects accurately. "
|
||||||
|
Reference in New Issue
Block a user