Commit 334c439c authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Fix bug that regular CONNECT does not work

parent 6700626c
......@@ -466,9 +466,8 @@ int nghttp2_http_on_header(nghttp2_session *session, nghttp2_stream *stream,
}
int nghttp2_http_on_request_headers(nghttp2_stream *stream,
nghttp2_frame *frame,
int connect_protocol) {
if (!connect_protocol &&
nghttp2_frame *frame) {
if (!(stream->http_flags & NGHTTP2_HTTP_FLAG__PROTOCOL) &&
(stream->http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT)) {
if ((stream->http_flags &
(NGHTTP2_HTTP_FLAG__SCHEME | NGHTTP2_HTTP_FLAG__PATH)) ||
......
......@@ -52,13 +52,11 @@ int nghttp2_http_on_header(nghttp2_session *session, nghttp2_stream *stream,
int trailer);
/*
* This function is called when request header is received.
* |connect_protocol| is nonzero if SETTINGS_ENABLE_CONNECT_PROTOCOL
* is enabled by the local endpoint (which must be server). This
* This function is called when request header is received. This
* function performs validation and returns 0 if it succeeds, or -1.
*/
int nghttp2_http_on_request_headers(nghttp2_stream *stream,
nghttp2_frame *frame, int connect_protocol);
nghttp2_frame *frame);
/*
* This function is called when response header is received. This
......
......@@ -3746,17 +3746,13 @@ static int session_after_header_block_received(nghttp2_session *session) {
subject_stream = nghttp2_session_get_stream(
session, frame->push_promise.promised_stream_id);
if (subject_stream) {
rv = nghttp2_http_on_request_headers(
subject_stream, frame,
session->server && session->pending_enable_connect_protocol);
rv = nghttp2_http_on_request_headers(subject_stream, frame);
}
} else {
assert(frame->hd.type == NGHTTP2_HEADERS);
switch (frame->headers.cat) {
case NGHTTP2_HCAT_REQUEST:
rv = nghttp2_http_on_request_headers(
stream, frame,
session->server && session->pending_enable_connect_protocol);
rv = nghttp2_http_on_request_headers(stream, frame);
break;
case NGHTTP2_HCAT_RESPONSE:
case NGHTTP2_HCAT_PUSH_RESPONSE:
......
......@@ -10922,6 +10922,8 @@ void test_nghttp2_http_mandatory_headers(void) {
MAKE_NV(":scheme", "http"), MAKE_NV(":path", "/"),
MAKE_NV(":method", "CONNECT"), MAKE_NV("host", "localhost"),
MAKE_NV(":protocol", "websocket")};
const nghttp2_nv regularconnect_reqnv[] = {
MAKE_NV(":method", "CONNECT"), MAKE_NV(":authority", "localhost")};
mem = nghttp2_mem_default();
......@@ -11107,6 +11109,12 @@ void test_nghttp2_http_mandatory_headers(void) {
connectprotonoauth_reqnv,
ARRLEN(connectprotonoauth_reqnv));
/* regular CONNECT method should succeed with
SETTINGS_CONNECT_PROTOCOL */
check_nghttp2_http_recv_headers_ok(session, &deflater, 9, -1,
regularconnect_reqnv,
ARRLEN(regularconnect_reqnv));
nghttp2_hd_deflate_free(&deflater);
nghttp2_session_del(session);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment