Commit e5cad54b authored by Denis Bilenko's avatar Denis Bilenko

test__pywsgi.py: add test that checks that 304 reply does not have message-body.

Note, that zero-length string encoded with chunked transfer-encoding is a non-empty message-body.
That causes some browsers to fail (e.g. safara and firefox on macos)

Thanks to Nicholas Piël.

--HG--
extra : transplant_source : %1B%B56%81%1F%87%BA%E9%ADdeE%7EAIm%F0%DDoz
parent 671ebbc4
......@@ -661,6 +661,39 @@ class TestEmptyYield(TestCase):
self.assert_(garbage == "", "got garbage: %r" % garbage)
class TestFirstEmptyYield(TestCase):
@staticmethod
def application(env, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
yield ""
yield "hello"
def test_err(self):
fd = self.connect().makefile(bufsize=1)
fd.write('GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n')
read_http(fd, body='hello', chunks=['hello'])
garbage = fd.read()
self.assert_(garbage == "", "got garbage: %r" % garbage)
class TestEmptyYield304(TestCase):
@staticmethod
def application(env, start_response):
start_response('304 Not modified', [])
yield ""
yield ""
def test_err(self):
fd = self.connect().makefile(bufsize=1)
fd.write('GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n')
read_http(fd, code=304, body='', chunks=False)
garbage = fd.read()
self.assert_(garbage == "", "got garbage: %r" % garbage)
class TestEmptyWrite(TestEmptyYield):
@staticmethod
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment