diff --git a/test/clients/h2ws.c b/test/clients/h2ws.c index 1de38760..1e35a9a5 100644 --- a/test/clients/h2ws.c +++ b/test/clients/h2ws.c @@ -490,7 +490,7 @@ static int h2_session_on_frame_recv(nghttp2_session *ngh2, const nghttp2_frame *frame, void *user_data) { - (void)user_data; + struct h2_session *session = user_data; switch (frame->hd.type) { case NGHTTP2_HEADERS: @@ -511,6 +511,8 @@ static int h2_session_on_frame_recv(nghttp2_session *ngh2, break; case NGHTTP2_GOAWAY: log_infof("frame recv", "FRAME[GOAWAY]"); + fprintf(stdout, "[%d] GOAWAY\n", frame->hd.stream_id); + session->aborted = 1; break; } return 0; @@ -744,6 +746,9 @@ static nfds_t h2_session_set_poll(struct h2_session *session, int want_read, want_write; struct h2_stream *stream; + if(session->aborted) + return 0; + want_read = (nghttp2_session_want_read(session->ngh2) || session->want_io == IO_WANT_READ); want_write = (nghttp2_session_want_write(session->ngh2) || diff --git a/test/modules/http2/test_003_get.py b/test/modules/http2/test_003_get.py index 2e52328c..b288848d 100644 --- a/test/modules/http2/test_003_get.py +++ b/test/modules/http2/test_003_get.py @@ -245,7 +245,7 @@ def test_h2_003_61(self, env): url = env.mkurl("https", "test1", "/index.html") r = env.curl_get(url, options=['-H', 'TE: gzip']) # such a request headers is not allowed in HTTP/2 - assert r.exit_code == 92, r + assert r.exit_code != 0, r # lets do some error tests def test_h2_003_70(self, env): diff --git a/test/modules/http2/test_800_websockets.py b/test/modules/http2/test_800_websockets.py index c0fc0c23..5d4f74dd 100644 --- a/test/modules/http2/test_800_websockets.py +++ b/test/modules/http2/test_800_websockets.py @@ -1,6 +1,7 @@ import inspect import logging import os +import re import shutil import subprocess import time @@ -73,8 +74,8 @@ def ws_run(env: H2TestEnv, path, authority=None, do_input=None, inbytes=None, proc.communicate(timeout=timeout) end = datetime.now() lines = open(f'{env.gen_dir}/h2ws.stdout').read().splitlines() - infos = [line for line in lines if line.startswith('[1] ')] - hex_content = ' '.join([line for line in lines if not line.startswith('[1] ')]) + infos = [line for line in lines if re.match(r'^\[\d+] ', line)] + hex_content = ' '.join([line for line in lines if not re.match(r'^\[\d+] ', line)]) if len(infos) > 0 and infos[0] == '[1] :status: 200': frames = WsFrameReader.parse(bytearray.fromhex(hex_content)) else: @@ -195,19 +196,19 @@ def test_h2_800_06_miss_version(self, env: H2TestEnv, ws_server): def test_h2_800_07_miss_path(self, env: H2TestEnv, ws_server): r, infos, frames = ws_run(env, path='/ws/echo/', scenario='miss-path') assert r.exit_code == 0, f'{r}' - assert infos == ['[1] RST'], f'{r}' + assert infos == ['[1] RST'] or infos == ['[0] GOAWAY'], f'{r}' # CONNECT missing the :scheme header def test_h2_800_08_miss_scheme(self, env: H2TestEnv, ws_server): r, infos, frames = ws_run(env, path='/ws/echo/', scenario='miss-scheme') assert r.exit_code == 0, f'{r}' - assert infos == ['[1] RST'], f'{r}' + assert infos == ['[1] RST'] or infos == ['[0] GOAWAY'], f'{r}' # CONNECT missing the :authority header def test_h2_800_09a_miss_authority(self, env: H2TestEnv, ws_server): r, infos, frames = ws_run(env, path='/ws/echo/', scenario='miss-authority') assert r.exit_code == 0, f'{r}' - assert infos == ['[1] RST'], f'{r}' + assert infos == ['[1] RST'] or infos == ['[0] GOAWAY'], f'{r}' # CONNECT to authority with disabled websockets def test_h2_800_09b_unsupported(self, env: H2TestEnv, ws_server):