From b80dfaa8a0e61b375b5f0f878ee1a56b7a3fbd64 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 23 Sep 2018 11:22:30 +0900 Subject: [PATCH] Adjustment for RFC 8441 --- lib/includes/nghttp2/nghttp2.h | 2 +- lib/nghttp2_http.c | 4 ++-- tests/nghttp2_session_test.c | 11 ++++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/includes/nghttp2/nghttp2.h b/lib/includes/nghttp2/nghttp2.h index 3fe4e2d5..e7198b3d 100644 --- a/lib/includes/nghttp2/nghttp2.h +++ b/lib/includes/nghttp2/nghttp2.h @@ -683,7 +683,7 @@ typedef enum { NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE = 0x06, /** * SETTINGS_ENABLE_CONNECT_PROTOCOL - * (https://tools.ietf.org/html/draft-ietf-httpbis-h2-websockets-00) + * (`RFC 8441 `_) */ NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL = 0x08 } nghttp2_settings_id; diff --git a/lib/nghttp2_http.c b/lib/nghttp2_http.c index 5ecd2d67..0c3a3712 100644 --- a/lib/nghttp2_http.c +++ b/lib/nghttp2_http.c @@ -484,8 +484,8 @@ int nghttp2_http_on_request_headers(nghttp2_stream *stream, return -1; } if ((stream->http_flags & NGHTTP2_HTTP_FLAG__PROTOCOL) && - (!connect_protocol || - (stream->http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT) == 0)) { + ((stream->http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT) == 0 || + (stream->http_flags & NGHTTP2_HTTP_FLAG__AUTHORITY) == 0)) { return -1; } if (!check_path(stream)) { diff --git a/tests/nghttp2_session_test.c b/tests/nghttp2_session_test.c index 5f284112..956ff6f7 100644 --- a/tests/nghttp2_session_test.c +++ b/tests/nghttp2_session_test.c @@ -10916,8 +10916,12 @@ void test_nghttp2_http_mandatory_headers(void) { MAKE_NV(":method", "GET"), MAKE_NV(":authority", "localhost"), MAKE_NV(":protocol", "websocket")}; const nghttp2_nv connectprotonopath_reqnv[] = { - MAKE_NV(":scheme", "https"), MAKE_NV(":method", "GET"), + MAKE_NV(":scheme", "https"), MAKE_NV(":method", "CONNECT"), MAKE_NV(":authority", "localhost"), MAKE_NV(":protocol", "websocket")}; + const nghttp2_nv connectprotonoauth_reqnv[] = { + MAKE_NV(":scheme", "http"), MAKE_NV(":path", "/"), + MAKE_NV(":method", "CONNECT"), MAKE_NV("host", "localhost"), + MAKE_NV(":protocol", "websocket")}; mem = nghttp2_mem_default(); @@ -11098,6 +11102,11 @@ void test_nghttp2_http_mandatory_headers(void) { connectprotonopath_reqnv, ARRLEN(connectprotonopath_reqnv)); + /* CONNECT method with :protocol requires :authority. */ + check_nghttp2_http_recv_headers_fail(session, &deflater, 7, -1, + connectprotonoauth_reqnv, + ARRLEN(connectprotonoauth_reqnv)); + nghttp2_hd_deflate_free(&deflater); nghttp2_session_del(session);