PICARD-1359: improve builtin server reliability and debugging output

This commit is contained in:
Laurent Monin
2018-10-02 18:26:56 +02:00
parent a11224258a
commit 263228eb94

View File

@@ -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("&")]