Mercurial > hg > nginx
comparison src/http/v2/ngx_http_v2.c @ 7191:61d276dcd493
HTTP/2: more style, comments, and debugging.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Mon, 29 Jan 2018 16:06:33 +0300 |
parents | e11a0679d349 |
children | d5a535774861 |
comparison
equal
deleted
inserted
replaced
7190:e11a0679d349 | 7191:61d276dcd493 |
---|---|
183 | 183 |
184 static void ngx_http_v2_pool_cleanup(void *data); | 184 static void ngx_http_v2_pool_cleanup(void *data); |
185 | 185 |
186 | 186 |
187 static ngx_http_v2_handler_pt ngx_http_v2_frame_states[] = { | 187 static ngx_http_v2_handler_pt ngx_http_v2_frame_states[] = { |
188 ngx_http_v2_state_data, | 188 ngx_http_v2_state_data, /* NGX_HTTP_V2_DATA_FRAME */ |
189 ngx_http_v2_state_headers, | 189 ngx_http_v2_state_headers, /* NGX_HTTP_V2_HEADERS_FRAME */ |
190 ngx_http_v2_state_priority, | 190 ngx_http_v2_state_priority, /* NGX_HTTP_V2_PRIORITY_FRAME */ |
191 ngx_http_v2_state_rst_stream, | 191 ngx_http_v2_state_rst_stream, /* NGX_HTTP_V2_RST_STREAM_FRAME */ |
192 ngx_http_v2_state_settings, | 192 ngx_http_v2_state_settings, /* NGX_HTTP_V2_SETTINGS_FRAME */ |
193 ngx_http_v2_state_push_promise, | 193 ngx_http_v2_state_push_promise, /* NGX_HTTP_V2_PUSH_PROMISE_FRAME */ |
194 ngx_http_v2_state_ping, | 194 ngx_http_v2_state_ping, /* NGX_HTTP_V2_PING_FRAME */ |
195 ngx_http_v2_state_goaway, | 195 ngx_http_v2_state_goaway, /* NGX_HTTP_V2_GOAWAY_FRAME */ |
196 ngx_http_v2_state_window_update, | 196 ngx_http_v2_state_window_update, /* NGX_HTTP_V2_WINDOW_UPDATE_FRAME */ |
197 ngx_http_v2_state_continuation | 197 ngx_http_v2_state_continuation /* NGX_HTTP_V2_CONTINUATION_FRAME */ |
198 }; | 198 }; |
199 | 199 |
200 #define NGX_HTTP_V2_FRAME_STATES \ | 200 #define NGX_HTTP_V2_FRAME_STATES \ |
201 (sizeof(ngx_http_v2_frame_states) / sizeof(ngx_http_v2_handler_pt)) | 201 (sizeof(ngx_http_v2_frame_states) / sizeof(ngx_http_v2_handler_pt)) |
202 | 202 |
1044 h2c->state.length -= h2c->state.padding; | 1044 h2c->state.length -= h2c->state.padding; |
1045 } | 1045 } |
1046 | 1046 |
1047 depend = 0; | 1047 depend = 0; |
1048 excl = 0; | 1048 excl = 0; |
1049 weight = 16; | 1049 weight = NGX_HTTP_V2_DEFAULT_WEIGHT; |
1050 | 1050 |
1051 if (priority) { | 1051 if (priority) { |
1052 dependency = ngx_http_v2_parse_uint32(pos); | 1052 dependency = ngx_http_v2_parse_uint32(pos); |
1053 | 1053 |
1054 depend = dependency & 0x7fffffff; | 1054 depend = dependency & 0x7fffffff; |
1057 | 1057 |
1058 pos += sizeof(uint32_t) + 1; | 1058 pos += sizeof(uint32_t) + 1; |
1059 } | 1059 } |
1060 | 1060 |
1061 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, | 1061 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
1062 "http2 HEADERS frame sid:%ui on %ui excl:%ui weight:%ui", | 1062 "http2 HEADERS frame sid:%ui " |
1063 "depends on %ui excl:%ui weight:%ui", | |
1063 h2c->state.sid, depend, excl, weight); | 1064 h2c->state.sid, depend, excl, weight); |
1064 | 1065 |
1065 if (h2c->state.sid % 2 == 0 || h2c->state.sid <= h2c->last_sid) { | 1066 if (h2c->state.sid % 2 == 0 || h2c->state.sid <= h2c->last_sid) { |
1066 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, | 1067 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
1067 "client sent HEADERS frame with incorrect identifier " | 1068 "client sent HEADERS frame with incorrect identifier " |
1786 weight = pos[4] + 1; | 1787 weight = pos[4] + 1; |
1787 | 1788 |
1788 pos += NGX_HTTP_V2_PRIORITY_SIZE; | 1789 pos += NGX_HTTP_V2_PRIORITY_SIZE; |
1789 | 1790 |
1790 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, | 1791 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, |
1791 "http2 PRIORITY frame sid:%ui on %ui excl:%ui weight:%ui", | 1792 "http2 PRIORITY frame sid:%ui " |
1793 "depends on %ui excl:%ui weight:%ui", | |
1792 h2c->state.sid, depend, excl, weight); | 1794 h2c->state.sid, depend, excl, weight); |
1793 | 1795 |
1794 if (h2c->state.sid == 0) { | 1796 if (h2c->state.sid == 0) { |
1795 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, | 1797 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
1796 "client sent PRIORITY frame with incorrect identifier"); | 1798 "client sent PRIORITY frame with incorrect identifier"); |
1983 | 1985 |
1984 h2c->state.length -= NGX_HTTP_V2_SETTINGS_PARAM_SIZE; | 1986 h2c->state.length -= NGX_HTTP_V2_SETTINGS_PARAM_SIZE; |
1985 | 1987 |
1986 id = ngx_http_v2_parse_uint16(pos); | 1988 id = ngx_http_v2_parse_uint16(pos); |
1987 value = ngx_http_v2_parse_uint32(&pos[2]); | 1989 value = ngx_http_v2_parse_uint32(&pos[2]); |
1990 | |
1991 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, | |
1992 "http2 setting %ui:%ui", id, value); | |
1988 | 1993 |
1989 switch (id) { | 1994 switch (id) { |
1990 | 1995 |
1991 case NGX_HTTP_V2_INIT_WINDOW_SIZE_SETTING: | 1996 case NGX_HTTP_V2_INIT_WINDOW_SIZE_SETTING: |
1992 | 1997 |
3341 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, | 3346 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
3342 "client sent no :method header"); | 3347 "client sent no :method header"); |
3343 | 3348 |
3344 } else if (r->schema_start == NULL) { | 3349 } else if (r->schema_start == NULL) { |
3345 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, | 3350 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
3346 "client sent no :schema header"); | 3351 "client sent no :scheme header"); |
3347 | 3352 |
3348 } else { | 3353 } else { |
3349 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, | 3354 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
3350 "client sent no :path header"); | 3355 "client sent no :path header"); |
3351 } | 3356 } |