Fix bug that regular CONNECT does not work

This commit is contained in:
Tatsuhiro Tsujikawa 2018-10-04 11:56:13 +09:00
parent 6700626c30
commit 334c439ce0
4 changed files with 14 additions and 13 deletions

View File

@ -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)) ||

View File

@ -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

View File

@ -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:

View File

@ -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);