From efbf8d7e0d7acb98f0347d8f1db4c8de1e6872bb Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 6 Jul 2021 01:03:09 +0200 Subject: [PATCH] better handling of invalid requests --- copyparty/httpcli.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 693d9335..58710ba4 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -95,9 +95,13 @@ class HttpCli(object): try: self.mode, self.req, self.http_ver = headerlines[0].split(" ") except: - raise Pebkac(400, "bad headers:\n" + "\n".join(headerlines)) + msg = " ]\n#[ ".join(headerlines) + raise Pebkac(400, "bad headers:\n#[ " + msg + " ]") except Pebkac as ex: + self.mode = "GET" + self.req = "[junk]" + self.http_ver = "HTTP/1.1" # self.log("pebkac at httpcli.run #1: " + repr(ex)) self.keepalive = self._check_nonfatal(ex) self.loud_reply(unicode(ex), status=ex.code)