diff options
author | David Glick <david@glicksoftware.com> | 2015-04-13 12:41:34 -0400 |
---|---|---|
committer | David Glick <david@glicksoftware.com> | 2015-04-13 12:41:34 -0400 |
commit | e555f4d1a2cd9d52fc907d2793930f74d29ff814 (patch) | |
tree | 4121e17d2c24d49c634da8f5ad64c1c10cd2630e /waitress | |
parent | e755d06eface5787e0c22d191d84df1e2d5bca0c (diff) | |
download | waitress-e555f4d1a2cd9d52fc907d2793930f74d29ff814.tar.gz |
preserve whitespace between folded header lines
Fixes #53
Diffstat (limited to 'waitress')
-rw-r--r-- | waitress/parser.py | 2 | ||||
-rw-r--r-- | waitress/tests/test_parser.py | 14 |
2 files changed, 14 insertions, 2 deletions
diff --git a/waitress/parser.py b/waitress/parser.py index dec96f6..9962b83 100644 --- a/waitress/parser.py +++ b/waitress/parser.py @@ -271,7 +271,7 @@ def get_header_lines(header): if not r: # http://corte.si/posts/code/pathod/pythonservers/index.html raise ParsingError('Malformed header line "%s"' % tostr(line)) - r[-1] = r[-1] + line[1:] + r[-1] += line else: r.append(line) return r diff --git a/waitress/tests/test_parser.py b/waitress/tests/test_parser.py index ed3a66c..423d75a 100644 --- a/waitress/tests/test_parser.py +++ b/waitress/tests/test_parser.py @@ -259,9 +259,21 @@ class Test_get_header_lines(unittest.TestCase): result = self._callFUT(b'slam\nslim') self.assertEqual(result, [b'slam', b'slim']) + def test_get_header_lines_folded(self): + # From RFC2616: + # HTTP/1.1 header field values can be folded onto multiple lines if the + # continuation line begins with a space or horizontal tab. All linear + # white space, including folding, has the same semantics as SP. A + # recipient MAY replace any linear white space with a single SP before + # interpreting the field value or forwarding the message downstream. + + # We are just preserving the whitespace that indicates folding. + result = self._callFUT(b'slim\n slam') + self.assertEqual(result, [b'slim slam']) + def test_get_header_lines_tabbed(self): result = self._callFUT(b'slam\n\tslim') - self.assertEqual(result, [b'slamslim']) + self.assertEqual(result, [b'slam\tslim']) def test_get_header_lines_malformed(self): # http://corte.si/posts/code/pathod/pythonservers/index.html |