Mercurial > hg > nginx
comparison src/http/ngx_http_spdy.c @ 5525:206c56e23a96
SPDY: better name for frame entries counter.
The "headers" is not a good term, since it is used not only to count
name/value pairs in the HEADERS block but to count SETTINGS entries too.
Moreover, one name/value pair in HEADERS can contain multiple http headers
with the same name.
No functional changes.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Wed, 22 Jan 2014 04:58:19 +0400 |
parents | 03c198bb2acf |
children | 2c6f82c0cec2 |
comparison
equal
deleted
inserted
replaced
5524:03c198bb2acf | 5525:206c56e23a96 |
---|---|
860 if (buf->last - buf->pos < NGX_SPDY_NV_NUM_SIZE) { | 860 if (buf->last - buf->pos < NGX_SPDY_NV_NUM_SIZE) { |
861 return ngx_http_spdy_state_save(sc, pos, end, | 861 return ngx_http_spdy_state_save(sc, pos, end, |
862 ngx_http_spdy_state_headers); | 862 ngx_http_spdy_state_headers); |
863 } | 863 } |
864 | 864 |
865 sc->headers = ngx_spdy_frame_parse_uint16(buf->pos); | 865 sc->entries = ngx_spdy_frame_parse_uint16(buf->pos); |
866 | 866 |
867 buf->pos += NGX_SPDY_NV_NUM_SIZE; | 867 buf->pos += NGX_SPDY_NV_NUM_SIZE; |
868 | 868 |
869 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 869 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
870 "spdy headers count: %ui", sc->headers); | 870 "spdy HEADERS block consists of %ui entries", |
871 | 871 sc->entries); |
872 if (ngx_list_init(&r->headers_in.headers, r->pool, sc->headers + 3, | 872 |
873 if (ngx_list_init(&r->headers_in.headers, r->pool, sc->entries + 3, | |
873 sizeof(ngx_table_elt_t)) | 874 sizeof(ngx_table_elt_t)) |
874 != NGX_OK) | 875 != NGX_OK) |
875 { | 876 { |
876 ngx_http_spdy_close_stream(sc->stream, | 877 ngx_http_spdy_close_stream(sc->stream, |
877 NGX_HTTP_INTERNAL_SERVER_ERROR); | 878 NGX_HTTP_INTERNAL_SERVER_ERROR); |
886 NGX_HTTP_INTERNAL_SERVER_ERROR); | 887 NGX_HTTP_INTERNAL_SERVER_ERROR); |
887 return ngx_http_spdy_state_headers_error(sc, pos, end); | 888 return ngx_http_spdy_state_headers_error(sc, pos, end); |
888 } | 889 } |
889 } | 890 } |
890 | 891 |
891 while (sc->headers) { | 892 while (sc->entries) { |
892 | 893 |
893 rc = ngx_http_spdy_parse_header(r); | 894 rc = ngx_http_spdy_parse_header(r); |
894 | 895 |
895 switch (rc) { | 896 switch (rc) { |
896 | 897 |
897 case NGX_DONE: | 898 case NGX_DONE: |
898 sc->headers--; | 899 sc->entries--; |
899 | 900 |
900 case NGX_OK: | 901 case NGX_OK: |
901 break; | 902 break; |
902 | 903 |
903 case NGX_AGAIN: | 904 case NGX_AGAIN: |
1399 u_char *end) | 1400 u_char *end) |
1400 { | 1401 { |
1401 ngx_uint_t v; | 1402 ngx_uint_t v; |
1402 ngx_http_spdy_srv_conf_t *sscf; | 1403 ngx_http_spdy_srv_conf_t *sscf; |
1403 | 1404 |
1404 if (sc->headers == 0) { | 1405 if (sc->entries == 0) { |
1405 | 1406 |
1406 if (end - pos < NGX_SPDY_SETTINGS_NUM_SIZE) { | 1407 if (end - pos < NGX_SPDY_SETTINGS_NUM_SIZE) { |
1407 return ngx_http_spdy_state_save(sc, pos, end, | 1408 return ngx_http_spdy_state_save(sc, pos, end, |
1408 ngx_http_spdy_state_settings); | 1409 ngx_http_spdy_state_settings); |
1409 } | 1410 } |
1410 | 1411 |
1411 sc->headers = ngx_spdy_frame_parse_uint32(pos); | 1412 sc->entries = ngx_spdy_frame_parse_uint32(pos); |
1412 | 1413 |
1413 pos += NGX_SPDY_SETTINGS_NUM_SIZE; | 1414 pos += NGX_SPDY_SETTINGS_NUM_SIZE; |
1414 sc->length -= NGX_SPDY_SETTINGS_NUM_SIZE; | 1415 sc->length -= NGX_SPDY_SETTINGS_NUM_SIZE; |
1415 | 1416 |
1416 if (sc->length < sc->headers * NGX_SPDY_SETTINGS_PAIR_SIZE) { | 1417 if (sc->length < sc->entries * NGX_SPDY_SETTINGS_PAIR_SIZE) { |
1417 /* TODO logging */ | 1418 /* TODO logging */ |
1418 return ngx_http_spdy_state_protocol_error(sc); | 1419 return ngx_http_spdy_state_protocol_error(sc); |
1419 } | 1420 } |
1420 | 1421 |
1421 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, sc->connection->log, 0, | 1422 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, sc->connection->log, 0, |
1422 "spdy SETTINGS frame consists of %ui entries", | 1423 "spdy SETTINGS frame consists of %ui entries", |
1423 sc->headers); | 1424 sc->entries); |
1424 } | 1425 } |
1425 | 1426 |
1426 while (sc->headers) { | 1427 while (sc->entries) { |
1427 if (end - pos < NGX_SPDY_SETTINGS_PAIR_SIZE) { | 1428 if (end - pos < NGX_SPDY_SETTINGS_PAIR_SIZE) { |
1428 return ngx_http_spdy_state_save(sc, pos, end, | 1429 return ngx_http_spdy_state_save(sc, pos, end, |
1429 ngx_http_spdy_state_settings); | 1430 ngx_http_spdy_state_settings); |
1430 } | 1431 } |
1431 | 1432 |
1432 sc->headers--; | 1433 sc->entries--; |
1433 | 1434 |
1434 if (pos[0] != NGX_SPDY_SETTINGS_MAX_STREAMS) { | 1435 if (pos[0] != NGX_SPDY_SETTINGS_MAX_STREAMS) { |
1435 pos += NGX_SPDY_SETTINGS_PAIR_SIZE; | 1436 pos += NGX_SPDY_SETTINGS_PAIR_SIZE; |
1436 sc->length -= NGX_SPDY_SETTINGS_PAIR_SIZE; | 1437 sc->length -= NGX_SPDY_SETTINGS_PAIR_SIZE; |
1437 continue; | 1438 continue; |