@@ -113,7 +113,7 @@ static int check_path(nghttp2_stream *stream){
113113}
114114
115115static int http_request_on_header (nghttp2_stream * stream , nghttp2_hd_nv * nv ,
116- int trailer ){
116+ int trailer , int connect_protocol ){
117117if (nv -> name -> base [0 ] == ':' ){
118118if (trailer ||
119119 (stream -> http_flags & NGHTTP2_HTTP_FLAG_PSEUDO_HEADER_DISALLOWED )){
@@ -146,10 +146,6 @@ static int http_request_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
146146return NGHTTP2_ERR_HTTP_HEADER ;
147147 }
148148stream -> http_flags |= NGHTTP2_HTTP_FLAG_METH_CONNECT ;
149- if (stream -> http_flags &
150- (NGHTTP2_HTTP_FLAG__PATH | NGHTTP2_HTTP_FLAG__SCHEME )){
151- return NGHTTP2_ERR_HTTP_HEADER ;
152- }
153149 }
154150break ;
155151case 'S' :
@@ -162,9 +158,6 @@ static int http_request_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
162158 }
163159break ;
164160case NGHTTP2_TOKEN__PATH :
165- if (stream -> http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT ){
166- return NGHTTP2_ERR_HTTP_HEADER ;
167- }
168161if (!check_pseudo_header (stream , nv , NGHTTP2_HTTP_FLAG__PATH )){
169162return NGHTTP2_ERR_HTTP_HEADER ;
170163 }
@@ -175,9 +168,6 @@ static int http_request_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
175168 }
176169break ;
177170case NGHTTP2_TOKEN__SCHEME :
178- if (stream -> http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT ){
179- return NGHTTP2_ERR_HTTP_HEADER ;
180- }
181171if (!check_pseudo_header (stream , nv , NGHTTP2_HTTP_FLAG__SCHEME )){
182172return NGHTTP2_ERR_HTTP_HEADER ;
183173 }
@@ -186,6 +176,15 @@ static int http_request_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
186176stream -> http_flags |= NGHTTP2_HTTP_FLAG_SCHEME_HTTP ;
187177 }
188178break ;
179+ case NGHTTP2_TOKEN__PROTOCOL :
180+ if (!connect_protocol ){
181+ return NGHTTP2_ERR_HTTP_HEADER ;
182+ }
183+
184+ if (!check_pseudo_header (stream , nv , NGHTTP2_HTTP_FLAG__PROTOCOL )){
185+ return NGHTTP2_ERR_HTTP_HEADER ;
186+ }
187+ break ;
189188case NGHTTP2_TOKEN_HOST :
190189if (!check_pseudo_header (stream , nv , NGHTTP2_HTTP_FLAG_HOST )){
191190return NGHTTP2_ERR_HTTP_HEADER ;
@@ -265,7 +264,7 @@ static int http_response_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
265264return NGHTTP2_ERR_REMOVE_HTTP_HEADER ;
266265 }
267266if (stream -> status_code / 100 == 1 ||
268- (stream -> status_code == 200 &&
267+ (stream -> status_code / 100 == 2 &&
269268 (stream -> http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT ))){
270269return NGHTTP2_ERR_HTTP_HEADER ;
271270 }
@@ -458,16 +457,21 @@ int nghttp2_http_on_header(nghttp2_session *session, nghttp2_stream *stream,
458457 }
459458
460459if (session -> server || frame -> hd .type == NGHTTP2_PUSH_PROMISE ){
461- return http_request_on_header (stream , nv , trailer );
460+ return http_request_on_header (stream , nv , trailer ,
461+ session -> server &&
462+ session -> pending_enable_connect_protocol );
462463 }
463464
464465return http_response_on_header (stream , nv , trailer );
465466}
466467
467468int nghttp2_http_on_request_headers (nghttp2_stream * stream ,
468469nghttp2_frame * frame ){
469- if (stream -> http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT ){
470- if ((stream -> http_flags & NGHTTP2_HTTP_FLAG__AUTHORITY ) == 0 ){
470+ if (!(stream -> http_flags & NGHTTP2_HTTP_FLAG__PROTOCOL ) &&
471+ (stream -> http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT )){
472+ if ((stream -> http_flags &
473+ (NGHTTP2_HTTP_FLAG__SCHEME | NGHTTP2_HTTP_FLAG__PATH )) ||
474+ (stream -> http_flags & NGHTTP2_HTTP_FLAG__AUTHORITY ) == 0 ){
471475return -1 ;
472476 }
473477stream -> content_length = -1 ;
@@ -478,6 +482,11 @@ int nghttp2_http_on_request_headers(nghttp2_stream *stream,
478482 (NGHTTP2_HTTP_FLAG__AUTHORITY | NGHTTP2_HTTP_FLAG_HOST )) == 0 ){
479483return -1 ;
480484 }
485+ if ((stream -> http_flags & NGHTTP2_HTTP_FLAG__PROTOCOL ) &&
486+ ((stream -> http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT ) == 0 ||
487+ (stream -> http_flags & NGHTTP2_HTTP_FLAG__AUTHORITY ) == 0 )){
488+ return -1 ;
489+ }
481490if (!check_path (stream )){
482491return -1 ;
483492 }
0 commit comments