MCPcopy
hub / github.com/tornadoweb/tornado / test_multi_line

Method test_multi_line

tornado/test/httputil_test.py:368–395  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

366
367class HTTPHeadersTest(unittest.TestCase):
368 def test_multi_line(self):
369 # Lines beginning with whitespace are appended to the previous line
370 # with any leading whitespace replaced by a single space.
371 # Note that while multi-line headers are a part of the HTTP spec,
372 # their use is strongly discouraged.
373 data = """\
374Foo: bar
375 baz
376Asdf: qwer
377\tzxcv
378Foo: even
379 more
380 lines
381""".replace(
382 "\n", "\r\n"
383 )
384 headers = HTTPHeaders.parse(data)
385 self.assertEqual(headers["asdf"], "qwer zxcv")
386 self.assertEqual(headers.get_list("asdf"), ["qwer zxcv"])
387 self.assertEqual(headers["Foo"], "bar baz,even more lines")
388 self.assertEqual(headers.get_list("foo"), ["bar baz", "even more lines"])
389 self.assertEqual(
390 sorted(list(headers.get_all())),
391 [("Asdf", "qwer zxcv"), ("Foo", "bar baz"), ("Foo", "even more lines")],
392 )
393 # Verify case insensitivity in-operator
394 self.assertTrue("asdf" in headers)
395 self.assertTrue("Asdf" in headers)
396
397 def test_continuation(self):
398 data = "Foo: bar\r\n\tasdf"

Callers

nothing calls this directly

Calls 4

replaceMethod · 0.80
get_listMethod · 0.80
get_allMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected