From 263228eb94e5eb3e2e879c991c7bc6a257de7ecc Mon Sep 17 00:00:00 2001 From: Laurent Monin Date: Tue, 2 Oct 2018 18:26:56 +0200 Subject: [PATCH] PICARD-1359: improve builtin server reliability and debugging output --- picard/browser/browser.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/picard/browser/browser.py b/picard/browser/browser.py index 0700be29e..84b3bf84b 100644 --- a/picard/browser/browser.py +++ b/picard/browser/browser.py @@ -65,11 +65,18 @@ class BrowserIntegration(QtNetwork.QTcpServer): def _process_request(self): conn = self.sender() - line = bytes(conn.readLine()).decode() conn.write(b"HTTP/1.1 200 OK\r\nCache-Control: max-age=0\r\n\r\nNothing to see here.") - conn.disconnectFromHost() + rawline = conn.readLine().data() + log.debug("Browser integration request: %r", rawline) + try: + line = rawline.decode() + except UnicodeDecodeError as e: + log.error(e) + return + finally: + conn.disconnectFromHost() + line = line.split() - log.debug("Browser integration request: %r", line) if line[0] == "GET" and "?" in line[1]: action, args = line[1].split("?") args = [a.split("=", 1) for a in args.split("&")]