keepalive debug

This commit is contained in:
ed 2019-07-16 21:46:38 +00:00
parent f11550538f
commit c09288880b
2 changed files with 10 additions and 1 deletions

View file

@ -42,11 +42,18 @@ class HttpCli(object):
def run(self):
"""returns true if connection can be reused"""
self.keepalive = False
self.headers = {}
try:
headerlines = read_header(self.sr)
if not headerlines:
return False
if not headerlines[0]:
# seen after login with IE6.0.2900.5512.xpsp.080413-2111 (xp-sp3)
self.log("\033[1;31mBUG: trailing newline from previous request\033[0m")
headerlines.pop(0)
try:
self.mode, self.req, _ = headerlines[0].split(" ")
except:
@ -56,7 +63,6 @@ class HttpCli(object):
self.loud_reply(str(ex), status=ex.code)
return False
self.headers = {}
for header_line in headerlines[1:]:
k, v = header_line.split(":", 1)
self.headers[k.lower()] = v.strip()

View file

@ -325,6 +325,9 @@ def read_header(sr):
ret += buf
if len(ret) > 1024 * 64:
raise Pebkac(400, "header 2big")
return ret[:-4].decode("utf-8", "surrogateescape").split("\r\n")