Browse Source

[core] fix crash when HTTP backend "Upgrade"s

Change-Id: If7143f49baa2efa8d1fb3f78c6390969730c678e
master
Stefan Bühler 1 year ago
parent
commit
d8bd405a19
2 changed files with 16 additions and 1 deletions
  1. +1
    -0
      src/main/stream_http_response.c
  2. +15
    -1
      tests/t-mod-proxy.py

+ 1
- 0
src/main/stream_http_response.c View File

@@ -82,6 +82,7 @@ static void check_response_header(liStreamHttpResponse* shr) {
li_vrequest_error(shr->vr);
return;
}
shr->wait_for_close = TRUE; /* forward all data until stream closes */
shr->response_headers_finished = TRUE;
shr->vr->backend_drain->out->is_closed = FALSE;
{


+ 15
- 1
tests/t-mod-proxy.py View File

@@ -30,6 +30,9 @@ class HttpBackendHandler(socketserver.StreamRequestHandler):
hdr = hdr.split(':', 2)
if hdr[0].lower() == "connection":
keepalive = (hdr[1].strip().lower() == "keep-alive")
if reqline[1].startswith("/upgrade/custom"):
self.wfile.write(b"HTTP/1.1 101 Switching Protocols\r\nConnection: Upgrade\r\nUpgrade: custom\r\n\r\nHello World!")
return
# send response
resp_body = reqline[1].encode('utf-8')
clen = "Content-Length: {}\r\n".format(len(resp_body)).encode('utf-8')
@@ -89,7 +92,7 @@ rewrite "/foo(.*)" => "/dest$1";
backend_proxy;
"""

# backend gets decoded %2F
# fake a backend forcing keep-alive mode
class TestBackendForcedKeepalive(CurlRequest):
URL = "/keepalive"
EXPECT_RESPONSE_BODY = "/keepalive"
@@ -99,12 +102,23 @@ class TestBackendForcedKeepalive(CurlRequest):
backend_proxy;
"""

# have backend "Upgrade"
class TestBackendUpgrade(CurlRequest):
URL = "/upgrade/custom"
EXPECT_RESPONSE_BODY = "Hello World!"
EXPECT_RESPONSE_CODE = 101
no_docroot = True
config = """
backend_proxy;
"""

class Test(GroupTest):
group = [
TestSimple,
TestProxiedRewrittenEncodedURL,
TestProxiedRewrittenDecodedURL,
TestBackendForcedKeepalive,
TestBackendUpgrade,
]

def Prepare(self):


Loading…
Cancel
Save