Merge "Ignore NoneType when encoding headers"

This commit is contained in:
Jenkins
2015-02-05 18:48:29 +00:00
committed by Gerrit Code Review
2 changed files with 3 additions and 2 deletions

View File

@@ -147,7 +147,7 @@ class HTTPClient(object):
names and values
"""
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):
"""Send an http request with the specified characteristics.

View File

@@ -163,9 +163,10 @@ class TestClient(testtools.TestCase):
def test_headers_encoding(self):
value = u'ni\xf1o'
headers = {"test": value}
headers = {"test": value, "none-val": None}
encoded = self.client.encode_headers(headers)
self.assertEqual(b"ni\xc3\xb1o", encoded[b"test"])
self.assertNotIn("none-val", encoded)
def test_raw_request(self):
" Verify the path being used for HTTP requests reflects accurately. "