comparison src/http/ngx_http_spdy.c @ 5694:9a95eb9f448b

SPDY: refactored ngx_http_spdy_state_headers(). This change is similar to d2ac5cf4056d. Special flag of completeness looks surplus when there is also a counter of frame bytes left.
author Valentin Bartenev <vbart@nginx.com>
date Wed, 30 Apr 2014 20:34:20 +0400
parents 701d6e17e42c
children 231588611230
comparison
equal deleted inserted replaced
5693:701d6e17e42c 5694:9a95eb9f448b
1007 { 1007 {
1008 int z; 1008 int z;
1009 size_t size; 1009 size_t size;
1010 ngx_buf_t *buf; 1010 ngx_buf_t *buf;
1011 ngx_int_t rc; 1011 ngx_int_t rc;
1012 ngx_uint_t complete;
1013 ngx_http_request_t *r; 1012 ngx_http_request_t *r;
1014 1013
1015 size = end - pos; 1014 size = end - pos;
1016 1015
1017 if (size == 0) { 1016 if (size == 0) {
1018 return ngx_http_spdy_state_save(sc, pos, end, 1017 return ngx_http_spdy_state_save(sc, pos, end,
1019 ngx_http_spdy_state_headers); 1018 ngx_http_spdy_state_headers);
1020 } 1019 }
1021 1020
1022 if (size >= sc->length) { 1021 if (size > sc->length) {
1023 size = sc->length; 1022 size = sc->length;
1024 complete = 1;
1025
1026 } else {
1027 complete = 0;
1028 } 1023 }
1029 1024
1030 r = sc->stream->request; 1025 r = sc->stream->request;
1031 1026
1032 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1027 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1087 1082
1088 if (r->headers_in.headers.part.elts == NULL) { 1083 if (r->headers_in.headers.part.elts == NULL) {
1089 1084
1090 if (buf->last - buf->pos < NGX_SPDY_NV_NUM_SIZE) { 1085 if (buf->last - buf->pos < NGX_SPDY_NV_NUM_SIZE) {
1091 1086
1092 if (complete) { 1087 if (sc->length == 0) {
1093 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1088 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1094 "premature end of spdy header block"); 1089 "premature end of spdy header block");
1095 1090
1096 return ngx_http_spdy_state_headers_error(sc, pos, end); 1091 return ngx_http_spdy_state_headers_error(sc, pos, end);
1097 } 1092 }
1179 buf->last = sc->zstream_in.next_out; 1174 buf->last = sc->zstream_in.next_out;
1180 1175
1181 continue; 1176 continue;
1182 } 1177 }
1183 1178
1184 if (complete) { 1179 if (sc->length == 0) {
1185 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1180 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1186 "premature end of spdy header block"); 1181 "premature end of spdy header block");
1187 1182
1188 return ngx_http_spdy_state_headers_error(sc, pos, end); 1183 return ngx_http_spdy_state_headers_error(sc, pos, end);
1189 } 1184 }
1223 "incorrect number of spdy header block entries"); 1218 "incorrect number of spdy header block entries");
1224 1219
1225 return ngx_http_spdy_state_headers_error(sc, pos, end); 1220 return ngx_http_spdy_state_headers_error(sc, pos, end);
1226 } 1221 }
1227 1222
1228 if (!complete) { 1223 if (sc->length) {
1229 return ngx_http_spdy_state_save(sc, pos, end, 1224 return ngx_http_spdy_state_save(sc, pos, end,
1230 ngx_http_spdy_state_headers); 1225 ngx_http_spdy_state_headers);
1231 } 1226 }
1232 1227
1233 /* null-terminate the last header value */ 1228 /* null-terminate the last header value */