comparison src/http/v2/ngx_http_v2.c @ 7200:cadb43014c7c

HTTP/2: changed prototypes of request pseudo-headers parsers. No functional changes.
author Ruslan Ermilov <ru@nginx.com>
date Thu, 08 Feb 2018 09:54:49 +0300
parents d5a535774861
children 641306096f5b
comparison
equal deleted inserted replaced
7199:6ba68ad8b24c 7200:cadb43014c7c
148 static ngx_int_t ngx_http_v2_validate_header(ngx_http_request_t *r, 148 static ngx_int_t ngx_http_v2_validate_header(ngx_http_request_t *r,
149 ngx_http_v2_header_t *header); 149 ngx_http_v2_header_t *header);
150 static ngx_int_t ngx_http_v2_pseudo_header(ngx_http_request_t *r, 150 static ngx_int_t ngx_http_v2_pseudo_header(ngx_http_request_t *r,
151 ngx_http_v2_header_t *header); 151 ngx_http_v2_header_t *header);
152 static ngx_int_t ngx_http_v2_parse_path(ngx_http_request_t *r, 152 static ngx_int_t ngx_http_v2_parse_path(ngx_http_request_t *r,
153 ngx_http_v2_header_t *header); 153 ngx_str_t *value);
154 static ngx_int_t ngx_http_v2_parse_method(ngx_http_request_t *r, 154 static ngx_int_t ngx_http_v2_parse_method(ngx_http_request_t *r,
155 ngx_http_v2_header_t *header); 155 ngx_str_t *value);
156 static ngx_int_t ngx_http_v2_parse_scheme(ngx_http_request_t *r, 156 static ngx_int_t ngx_http_v2_parse_scheme(ngx_http_request_t *r,
157 ngx_http_v2_header_t *header); 157 ngx_str_t *value);
158 static ngx_int_t ngx_http_v2_parse_authority(ngx_http_request_t *r, 158 static ngx_int_t ngx_http_v2_parse_authority(ngx_http_request_t *r,
159 ngx_http_v2_header_t *header); 159 ngx_str_t *value);
160 static ngx_int_t ngx_http_v2_construct_request_line(ngx_http_request_t *r); 160 static ngx_int_t ngx_http_v2_construct_request_line(ngx_http_request_t *r);
161 static ngx_int_t ngx_http_v2_cookie(ngx_http_request_t *r, 161 static ngx_int_t ngx_http_v2_cookie(ngx_http_request_t *r,
162 ngx_http_v2_header_t *header); 162 ngx_http_v2_header_t *header);
163 static ngx_int_t ngx_http_v2_construct_cookie_header(ngx_http_request_t *r); 163 static ngx_int_t ngx_http_v2_construct_cookie_header(ngx_http_request_t *r);
164 static void ngx_http_v2_run_request(ngx_http_request_t *r); 164 static void ngx_http_v2_run_request(ngx_http_request_t *r);
3080 switch (header->name.len) { 3080 switch (header->name.len) {
3081 case 4: 3081 case 4:
3082 if (ngx_memcmp(header->name.data, "path", sizeof("path") - 1) 3082 if (ngx_memcmp(header->name.data, "path", sizeof("path") - 1)
3083 == 0) 3083 == 0)
3084 { 3084 {
3085 return ngx_http_v2_parse_path(r, header); 3085 return ngx_http_v2_parse_path(r, &header->value);
3086 } 3086 }
3087 3087
3088 break; 3088 break;
3089 3089
3090 case 6: 3090 case 6:
3091 if (ngx_memcmp(header->name.data, "method", sizeof("method") - 1) 3091 if (ngx_memcmp(header->name.data, "method", sizeof("method") - 1)
3092 == 0) 3092 == 0)
3093 { 3093 {
3094 return ngx_http_v2_parse_method(r, header); 3094 return ngx_http_v2_parse_method(r, &header->value);
3095 } 3095 }
3096 3096
3097 if (ngx_memcmp(header->name.data, "scheme", sizeof("scheme") - 1) 3097 if (ngx_memcmp(header->name.data, "scheme", sizeof("scheme") - 1)
3098 == 0) 3098 == 0)
3099 { 3099 {
3100 return ngx_http_v2_parse_scheme(r, header); 3100 return ngx_http_v2_parse_scheme(r, &header->value);
3101 } 3101 }
3102 3102
3103 break; 3103 break;
3104 3104
3105 case 9: 3105 case 9:
3106 if (ngx_memcmp(header->name.data, "authority", sizeof("authority") - 1) 3106 if (ngx_memcmp(header->name.data, "authority", sizeof("authority") - 1)
3107 == 0) 3107 == 0)
3108 { 3108 {
3109 return ngx_http_v2_parse_authority(r, header); 3109 return ngx_http_v2_parse_authority(r, &header->value);
3110 } 3110 }
3111 3111
3112 break; 3112 break;
3113 } 3113 }
3114 3114
3119 return NGX_DECLINED; 3119 return NGX_DECLINED;
3120 } 3120 }
3121 3121
3122 3122
3123 static ngx_int_t 3123 static ngx_int_t
3124 ngx_http_v2_parse_path(ngx_http_request_t *r, ngx_http_v2_header_t *header) 3124 ngx_http_v2_parse_path(ngx_http_request_t *r, ngx_str_t *value)
3125 { 3125 {
3126 if (r->unparsed_uri.len) { 3126 if (r->unparsed_uri.len) {
3127 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, 3127 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
3128 "client sent duplicate :path header"); 3128 "client sent duplicate :path header");
3129 3129
3130 return NGX_DECLINED; 3130 return NGX_DECLINED;
3131 } 3131 }
3132 3132
3133 if (header->value.len == 0) { 3133 if (value->len == 0) {
3134 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, 3134 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
3135 "client sent empty :path header"); 3135 "client sent empty :path header");
3136 3136
3137 return NGX_DECLINED; 3137 return NGX_DECLINED;
3138 } 3138 }
3139 3139
3140 r->uri_start = header->value.data; 3140 r->uri_start = value->data;
3141 r->uri_end = header->value.data + header->value.len; 3141 r->uri_end = value->data + value->len;
3142 3142
3143 if (ngx_http_parse_uri(r) != NGX_OK) { 3143 if (ngx_http_parse_uri(r) != NGX_OK) {
3144 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, 3144 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
3145 "client sent invalid :path header: \"%V\"", 3145 "client sent invalid :path header: \"%V\"", value);
3146 &header->value);
3147 3146
3148 return NGX_DECLINED; 3147 return NGX_DECLINED;
3149 } 3148 }
3150 3149
3151 if (ngx_http_process_request_uri(r) != NGX_OK) { 3150 if (ngx_http_process_request_uri(r) != NGX_OK) {
3159 return NGX_OK; 3158 return NGX_OK;
3160 } 3159 }
3161 3160
3162 3161
3163 static ngx_int_t 3162 static ngx_int_t
3164 ngx_http_v2_parse_method(ngx_http_request_t *r, ngx_http_v2_header_t *header) 3163 ngx_http_v2_parse_method(ngx_http_request_t *r, ngx_str_t *value)
3165 { 3164 {
3166 size_t k, len; 3165 size_t k, len;
3167 ngx_uint_t n; 3166 ngx_uint_t n;
3168 const u_char *p, *m; 3167 const u_char *p, *m;
3169 3168
3199 "client sent duplicate :method header"); 3198 "client sent duplicate :method header");
3200 3199
3201 return NGX_DECLINED; 3200 return NGX_DECLINED;
3202 } 3201 }
3203 3202
3204 if (header->value.len == 0) { 3203 if (value->len == 0) {
3205 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, 3204 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
3206 "client sent empty :method header"); 3205 "client sent empty :method header");
3207 3206
3208 return NGX_DECLINED; 3207 return NGX_DECLINED;
3209 } 3208 }
3210 3209
3211 r->method_name.len = header->value.len; 3210 r->method_name.len = value->len;
3212 r->method_name.data = header->value.data; 3211 r->method_name.data = value->data;
3213 3212
3214 len = r->method_name.len; 3213 len = r->method_name.len;
3215 n = sizeof(tests) / sizeof(tests[0]); 3214 n = sizeof(tests) / sizeof(tests[0]);
3216 test = tests; 3215 test = tests;
3217 3216
3254 return NGX_OK; 3253 return NGX_OK;
3255 } 3254 }
3256 3255
3257 3256
3258 static ngx_int_t 3257 static ngx_int_t
3259 ngx_http_v2_parse_scheme(ngx_http_request_t *r, ngx_http_v2_header_t *header) 3258 ngx_http_v2_parse_scheme(ngx_http_request_t *r, ngx_str_t *value)
3260 { 3259 {
3261 if (r->schema_start) { 3260 if (r->schema_start) {
3262 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, 3261 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
3263 "client sent duplicate :scheme header"); 3262 "client sent duplicate :scheme header");
3264 3263
3265 return NGX_DECLINED; 3264 return NGX_DECLINED;
3266 } 3265 }
3267 3266
3268 if (header->value.len == 0) { 3267 if (value->len == 0) {
3269 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, 3268 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
3270 "client sent empty :scheme header"); 3269 "client sent empty :scheme header");
3271 3270
3272 return NGX_DECLINED; 3271 return NGX_DECLINED;
3273 } 3272 }
3274 3273
3275 r->schema_start = header->value.data; 3274 r->schema_start = value->data;
3276 r->schema_end = header->value.data + header->value.len; 3275 r->schema_end = value->data + value->len;
3277 3276
3278 return NGX_OK; 3277 return NGX_OK;
3279 } 3278 }
3280 3279
3281 3280
3282 static ngx_int_t 3281 static ngx_int_t
3283 ngx_http_v2_parse_authority(ngx_http_request_t *r, ngx_http_v2_header_t *header) 3282 ngx_http_v2_parse_authority(ngx_http_request_t *r, ngx_str_t *value)
3284 { 3283 {
3285 ngx_table_elt_t *h; 3284 ngx_table_elt_t *h;
3286 ngx_http_header_t *hh; 3285 ngx_http_header_t *hh;
3287 ngx_http_core_main_conf_t *cmcf; 3286 ngx_http_core_main_conf_t *cmcf;
3288 3287
3296 h->hash = ngx_hash_key(host.data, host.len); 3295 h->hash = ngx_hash_key(host.data, host.len);
3297 3296
3298 h->key.len = host.len; 3297 h->key.len = host.len;
3299 h->key.data = host.data; 3298 h->key.data = host.data;
3300 3299
3301 h->value.len = header->value.len; 3300 h->value.len = value->len;
3302 h->value.data = header->value.data; 3301 h->value.data = value->data;
3303 3302
3304 h->lowcase_key = host.data; 3303 h->lowcase_key = host.data;
3305 3304
3306 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); 3305 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
3307 3306