Skip to content

Commit 1b352c5

Browse files
authored
websocket tests, fix interworking with recent httpd+nghttp2 versions (#308)
1 parent 028f67b commit 1b352c5

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

test/clients/h2ws.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ static int h2_session_on_frame_recv(nghttp2_session *ngh2,
490490
const nghttp2_frame *frame,
491491
void *user_data)
492492
{
493-
(void)user_data;
493+
struct h2_session *session = user_data;
494494

495495
switch (frame->hd.type) {
496496
case NGHTTP2_HEADERS:
@@ -511,6 +511,8 @@ static int h2_session_on_frame_recv(nghttp2_session *ngh2,
511511
break;
512512
case NGHTTP2_GOAWAY:
513513
log_infof("frame recv", "FRAME[GOAWAY]");
514+
fprintf(stdout, "[%d] GOAWAY\n", frame->hd.stream_id);
515+
session->aborted = 1;
514516
break;
515517
}
516518
return 0;
@@ -744,6 +746,9 @@ static nfds_t h2_session_set_poll(struct h2_session *session,
744746
int want_read, want_write;
745747
struct h2_stream *stream;
746748

749+
if(session->aborted)
750+
return 0;
751+
747752
want_read = (nghttp2_session_want_read(session->ngh2) ||
748753
session->want_io == IO_WANT_READ);
749754
want_write = (nghttp2_session_want_write(session->ngh2) ||

test/modules/http2/test_003_get.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def test_h2_003_61(self, env):
245245
url = env.mkurl("https", "test1", "/index.html")
246246
r = env.curl_get(url, options=['-H', 'TE: gzip'])
247247
# such a request headers is not allowed in HTTP/2
248-
assert r.exit_code == 92, r
248+
assert r.exit_code != 0, r
249249

250250
# lets do some error tests
251251
def test_h2_003_70(self, env):

test/modules/http2/test_800_websockets.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import inspect
22
import logging
33
import os
4+
import re
45
import shutil
56
import subprocess
67
import time
@@ -73,8 +74,8 @@ def ws_run(env: H2TestEnv, path, authority=None, do_input=None, inbytes=None,
7374
proc.communicate(timeout=timeout)
7475
end = datetime.now()
7576
lines = open(f'{env.gen_dir}/h2ws.stdout').read().splitlines()
76-
infos = [line for line in lines if line.startswith('[1] ')]
77-
hex_content = ' '.join([line for line in lines if not line.startswith('[1] ')])
77+
infos = [line for line in lines if re.match(r'^\[\d+] ', line)]
78+
hex_content = ' '.join([line for line in lines if not re.match(r'^\[\d+] ', line)])
7879
if len(infos) > 0 and infos[0] == '[1] :status: 200':
7980
frames = WsFrameReader.parse(bytearray.fromhex(hex_content))
8081
else:
@@ -195,19 +196,19 @@ def test_h2_800_06_miss_version(self, env: H2TestEnv, ws_server):
195196
def test_h2_800_07_miss_path(self, env: H2TestEnv, ws_server):
196197
r, infos, frames = ws_run(env, path='/ws/echo/', scenario='miss-path')
197198
assert r.exit_code == 0, f'{r}'
198-
assert infos == ['[1] RST'], f'{r}'
199+
assert infos == ['[1] RST'] or infos == ['[0] GOAWAY'], f'{r}'
199200

200201
# CONNECT missing the :scheme header
201202
def test_h2_800_08_miss_scheme(self, env: H2TestEnv, ws_server):
202203
r, infos, frames = ws_run(env, path='/ws/echo/', scenario='miss-scheme')
203204
assert r.exit_code == 0, f'{r}'
204-
assert infos == ['[1] RST'], f'{r}'
205+
assert infos == ['[1] RST'] or infos == ['[0] GOAWAY'], f'{r}'
205206

206207
# CONNECT missing the :authority header
207208
def test_h2_800_09a_miss_authority(self, env: H2TestEnv, ws_server):
208209
r, infos, frames = ws_run(env, path='/ws/echo/', scenario='miss-authority')
209210
assert r.exit_code == 0, f'{r}'
210-
assert infos == ['[1] RST'], f'{r}'
211+
assert infos == ['[1] RST'] or infos == ['[0] GOAWAY'], f'{r}'
211212

212213
# CONNECT to authority with disabled websockets
213214
def test_h2_800_09b_unsupported(self, env: H2TestEnv, ws_server):

0 commit comments

Comments
 (0)