From 1ca25d4e2cfeb83c844ad52b9c94eac218c71379 Mon Sep 17 00:00:00 2001
From: Glenn Strauss <gstrauss@gluelogic.com>
Date: Thu, 4 Feb 2021 00:22:12 -0500
Subject: [PATCH] [core] 101 upgrade fails if Content-Length incl (fixes #3063)

(thx daimh)

commit 903024d7 in lighttpd 1.4.57 fixed issue #3046 but in the process
broke HTTP/1.1 101 Switching Protocols which included Content-Length: 0
in the response headers.  Content-Length response header is permitted
by the RFCs, but not necessary with HTTP status 101 Switching Protocols.

x-ref:
  "websocket proxy fails if 101 Switching Protocols from backend includes Content-Length"
  https://redmine.lighttpd.net/issues/3063
---
 src/http-header-glue.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/http-header-glue.c b/src/http-header-glue.c
index 6531843c..c2982951 100644
--- a/src/http-header-glue.c
+++ b/src/http-header-glue.c
@@ -961,6 +961,7 @@ void http_response_upgrade_read_body_unknown(request_st * const r) {
           (FDEVENT_STREAM_RESPONSE_BUFMIN | FDEVENT_STREAM_RESPONSE);
     r->conf.stream_request_body |= FDEVENT_STREAM_REQUEST_POLLIN;
     r->reqbody_length = -2;
+    r->resp_body_scratchpad = -1;
     r->keep_alive = 0;
 }
 
-- 
2.29.2

