diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2018-11-23 02:11:16 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-23 02:11:16 -0600 |
commit | 4ca9959663f927c051b0248f90cb4a479114b4be (patch) | |
tree | fe2dee1ada0c3500942a790cc3980740bdb7e9f4 | |
parent | 545a4d24fb93c95507bba992ba8559c07b9adacd (diff) | |
parent | a9a0a08fa9c03036d6e59bde4abcf281b058dac0 (diff) | |
download | cherrypy-git-4ca9959663f927c051b0248f90cb4a479114b4be.tar.gz |
Merge pull request #1755 from h3llrais3r/byte-headers
Don't convert bytes headers to str
-rw-r--r-- | cherrypy/lib/httputil.py | 3 | ||||
-rw-r--r-- | cherrypy/test/test_encoding.py | 7 |
2 files changed, 9 insertions, 1 deletions
diff --git a/cherrypy/lib/httputil.py b/cherrypy/lib/httputil.py index b68d8dd5..59bcc746 100644 --- a/cherrypy/lib/httputil.py +++ b/cherrypy/lib/httputil.py @@ -518,7 +518,8 @@ class HeaderMap(CaseInsensitiveDict): transmitting on the wire for HTTP. """ for k, v in header_items: - if not isinstance(v, six.string_types): + if not isinstance(v, six.string_types) and \ + not isinstance(v, six.binary_type): v = six.text_type(v) yield tuple(map(cls.encode_header_item, (k, v))) diff --git a/cherrypy/test/test_encoding.py b/cherrypy/test/test_encoding.py index ab24ab93..26b0aa18 100644 --- a/cherrypy/test/test_encoding.py +++ b/cherrypy/test/test_encoding.py @@ -50,6 +50,8 @@ class EncodingTests(helper.CPWebCase): cherrypy.response.cookie['candy']['domain'] = 'cherrypy.org' cherrypy.response.headers[ 'Some-Header'] = 'My d\xc3\xb6g has fleas' + cherrypy.response.headers[ + 'Bytes-Header'] = b'Bytes given header' return 'Any content' @cherrypy.expose @@ -424,3 +426,8 @@ class EncodingTests(helper.CPWebCase): def test_UnicodeHeaders(self): self.getPage('/cookies_and_headers') self.assertBody('Any content') + + def test_BytesHeaders(self): + self.getPage('/cookies_and_headers') + self.assertBody('Any content') + self.assertHeader('Bytes-Header', 'Bytes given header') |