diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 7ff7ad6a..22585a3f 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -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() diff --git a/copyparty/util.py b/copyparty/util.py index e6b82de2..48984406 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -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")