From da59085bcc081eab2744f6893626a3ee1ce9b7a9 Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Tue, 1 Dec 2020 20:12:27 +0100 Subject: [PATCH] Websocket debug --- src/client.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index 0afb664..07b4f9e 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -260,7 +260,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col } try { - bool noRedirect, redir, invalidMethod, etag, compress, websocket; + bool noRedirect, redir, invalidMethod, etag, compress, wantsWebsocket, websocket = false; URI path; pid_t childpid; FILE *file; @@ -424,7 +424,8 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col : ((req.getMethod() == "POST" || req.getMethod() == "PUT") ? -1 : 0); socket->receive(pipes.stdin, len); - if (req.getMethod() != "GET") { + wantsWebsocket = req.getMethod() == "GET" && req.getField("Connection") == "Upgrade"; + if (!wantsWebsocket) { // Close only if no Websocket upgrade is possible fclose(pipes.stdin); }