comparison src/http/v2/ngx_http_v2_filter_module.c @ 6292:f72d3129cd35

HTTP/2: fixed handling of output HEADERS frames. The HEADERS frame is always represented by more than one buffer since b930e598a199, but the handling code hasn't been adjusted. Only the first buffer of HEADERS frame was checked and if it had been sent while others had not, the rest of the frame was dropped, resulting in broken connection. Before b930e598a199, the problem could only be seen in case of HEADERS frame with CONTINUATION.
author Valentin Bartenev <vbart@nginx.com>
date Fri, 13 Nov 2015 20:10:50 +0300
parents c72eaf694d99
children ec6b07be88a5
comparison
equal deleted inserted replaced
6291:932a465537ef 6292:f72d3129cd35
1052 1052
1053 static ngx_int_t 1053 static ngx_int_t
1054 ngx_http_v2_headers_frame_handler(ngx_http_v2_connection_t *h2c, 1054 ngx_http_v2_headers_frame_handler(ngx_http_v2_connection_t *h2c,
1055 ngx_http_v2_out_frame_t *frame) 1055 ngx_http_v2_out_frame_t *frame)
1056 { 1056 {
1057 ngx_buf_t *buf; 1057 ngx_chain_t *cl;
1058 ngx_http_v2_stream_t *stream; 1058 ngx_http_v2_stream_t *stream;
1059 1059
1060 buf = frame->first->buf;
1061
1062 if (buf->pos != buf->last) {
1063 return NGX_AGAIN;
1064 }
1065
1066 stream = frame->stream; 1060 stream = frame->stream;
1061 cl = frame->first;
1062
1063 for ( ;; ) {
1064 if (cl->buf->pos != cl->buf->last) {
1065 frame->first = cl;
1066
1067 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0,
1068 "http2:%ui HEADERS frame %p was sent partially",
1069 stream->node->id, frame);
1070
1071 return NGX_AGAIN;
1072 }
1073
1074 if (cl == frame->last) {
1075 break;
1076 }
1077
1078 cl = cl->next;
1079 }
1067 1080
1068 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, 1081 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0,
1069 "http2:%ui HEADERS frame %p was sent", 1082 "http2:%ui HEADERS frame %p was sent",
1070 stream->node->id, frame); 1083 stream->node->id, frame);
1071 1084