def test_016_repeated_content_length(self):
"""content-length header was being doubled up if it was set in
start_response and could also be inferred from the iterator
"""
def wsgi_app(environ, start_response):
start_response('200 OK', [('Content-Length', '7')])
return [b'testing']
self.site.application = wsgi_app
sock = eventlet.connect(self.server_addr)
fd = sock.makefile('rwb')
fd.write(b'GET /a HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n')
fd.flush()
header_lines = []
while True:
line = fd.readline()
if line == b'\r\n':
break
else:
header_lines.append(line)
self.assertEqual(1, len(
[l for l in header_lines if l.lower().startswith(b'content-length')]))
评论列表
文章目录