Mercurial > hg > nginx
comparison src/http/v2/ngx_http_v2.c @ 6513:80ba811112ed
HTTP/2: deduplicated some code in ngx_http_v2_state_headers().
No functional changes.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Thu, 14 Apr 2016 15:14:15 +0300 |
parents | 9d66d7ed2abb |
children | 0aa07850922f |
comparison
equal
deleted
inserted
replaced
6512:b5734248d5e7 | 6513:80ba811112ed |
---|---|
946 ngx_http_v2_state_headers(ngx_http_v2_connection_t *h2c, u_char *pos, | 946 ngx_http_v2_state_headers(ngx_http_v2_connection_t *h2c, u_char *pos, |
947 u_char *end) | 947 u_char *end) |
948 { | 948 { |
949 size_t size; | 949 size_t size; |
950 ngx_uint_t padded, priority, depend, dependency, excl, weight; | 950 ngx_uint_t padded, priority, depend, dependency, excl, weight; |
951 ngx_uint_t status; | |
951 ngx_http_v2_node_t *node; | 952 ngx_http_v2_node_t *node; |
952 ngx_http_v2_stream_t *stream; | 953 ngx_http_v2_stream_t *stream; |
953 ngx_http_v2_srv_conf_t *h2scf; | 954 ngx_http_v2_srv_conf_t *h2scf; |
954 | 955 |
955 padded = h2c->state.flags & NGX_HTTP_V2_PADDED_FLAG; | 956 padded = h2c->state.flags & NGX_HTTP_V2_PADDED_FLAG; |
1038 if (depend == h2c->state.sid) { | 1039 if (depend == h2c->state.sid) { |
1039 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, | 1040 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
1040 "client sent HEADERS frame for stream %ui " | 1041 "client sent HEADERS frame for stream %ui " |
1041 "with incorrect dependency", h2c->state.sid); | 1042 "with incorrect dependency", h2c->state.sid); |
1042 | 1043 |
1043 if (ngx_http_v2_send_rst_stream(h2c, h2c->state.sid, | 1044 status = NGX_HTTP_V2_PROTOCOL_ERROR; |
1044 NGX_HTTP_V2_PROTOCOL_ERROR) | 1045 goto rst_stream; |
1045 != NGX_OK) | |
1046 { | |
1047 return ngx_http_v2_connection_error(h2c, | |
1048 NGX_HTTP_V2_INTERNAL_ERROR); | |
1049 } | |
1050 | |
1051 return ngx_http_v2_state_header_block(h2c, pos, end); | |
1052 } | 1046 } |
1053 | 1047 |
1054 h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx, | 1048 h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx, |
1055 ngx_http_v2_module); | 1049 ngx_http_v2_module); |
1056 | 1050 |
1058 | 1052 |
1059 if (h2c->processing >= h2scf->concurrent_streams) { | 1053 if (h2c->processing >= h2scf->concurrent_streams) { |
1060 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, | 1054 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, |
1061 "concurrent streams exceeded %ui", h2c->processing); | 1055 "concurrent streams exceeded %ui", h2c->processing); |
1062 | 1056 |
1063 if (ngx_http_v2_send_rst_stream(h2c, h2c->state.sid, | 1057 status = NGX_HTTP_V2_REFUSED_STREAM; |
1064 NGX_HTTP_V2_REFUSED_STREAM) | 1058 goto rst_stream; |
1065 != NGX_OK) | |
1066 { | |
1067 return ngx_http_v2_connection_error(h2c, | |
1068 NGX_HTTP_V2_INTERNAL_ERROR); | |
1069 } | |
1070 | |
1071 return ngx_http_v2_state_header_block(h2c, pos, end); | |
1072 } | 1059 } |
1073 | 1060 |
1074 node = ngx_http_v2_get_node_by_id(h2c, h2c->state.sid, 1); | 1061 node = ngx_http_v2_get_node_by_id(h2c, h2c->state.sid, 1); |
1075 | 1062 |
1076 if (node == NULL) { | 1063 if (node == NULL) { |
1100 node->stream = stream; | 1087 node->stream = stream; |
1101 | 1088 |
1102 if (priority || node->parent == NULL) { | 1089 if (priority || node->parent == NULL) { |
1103 node->weight = weight; | 1090 node->weight = weight; |
1104 ngx_http_v2_set_dependency(h2c, node, depend, excl); | 1091 ngx_http_v2_set_dependency(h2c, node, depend, excl); |
1092 } | |
1093 | |
1094 return ngx_http_v2_state_header_block(h2c, pos, end); | |
1095 | |
1096 rst_stream: | |
1097 | |
1098 if (ngx_http_v2_send_rst_stream(h2c, h2c->state.sid, status) != NGX_OK) { | |
1099 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR); | |
1105 } | 1100 } |
1106 | 1101 |
1107 return ngx_http_v2_state_header_block(h2c, pos, end); | 1102 return ngx_http_v2_state_header_block(h2c, pos, end); |
1108 } | 1103 } |
1109 | 1104 |