Mercurial > hg > nginx-quic
annotate src/http/v3/ngx_http_v3_request.c @ 8605:4ca8035c19a4 quic
Merged with the default branch.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 08 Sep 2021 15:53:00 +0300 |
parents | d6e191a583cc |
children | e29c1ede905f |
rev | line source |
---|---|
7681 | 1 |
2 /* | |
3 * Copyright (C) Roman Arutyunyan | |
4 * Copyright (C) Nginx, Inc. | |
5 */ | |
6 | |
7 | |
8 #include <ngx_config.h> | |
9 #include <ngx_core.h> | |
10 #include <ngx_http.h> | |
11 | |
12 | |
8360
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
13 static void ngx_http_v3_cleanup_request(void *data); |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
14 static void ngx_http_v3_process_request(ngx_event_t *rev); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
15 static ngx_int_t ngx_http_v3_process_header(ngx_http_request_t *r, |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
16 ngx_str_t *name, ngx_str_t *value); |
8275
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
17 static ngx_int_t ngx_http_v3_validate_header(ngx_http_request_t *r, |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
18 ngx_str_t *name, ngx_str_t *value); |
7681 | 19 static ngx_int_t ngx_http_v3_process_pseudo_header(ngx_http_request_t *r, |
20 ngx_str_t *name, ngx_str_t *value); | |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
21 static ngx_int_t ngx_http_v3_init_pseudo_headers(ngx_http_request_t *r); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
22 static ngx_int_t ngx_http_v3_process_request_header(ngx_http_request_t *r); |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
23 static void ngx_http_v3_read_client_request_body_handler(ngx_http_request_t *r); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
24 static ngx_int_t ngx_http_v3_do_read_client_request_body(ngx_http_request_t *r); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
25 static ngx_int_t ngx_http_v3_request_body_filter(ngx_http_request_t *r, |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
26 ngx_chain_t *in); |
7681 | 27 |
28 | |
8258
96eb6915d244
HTTP/3: staticize ngx_http_v3_methods.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8237
diff
changeset
|
29 static const struct { |
7681 | 30 ngx_str_t name; |
31 ngx_uint_t method; | |
32 } ngx_http_v3_methods[] = { | |
33 | |
34 { ngx_string("GET"), NGX_HTTP_GET }, | |
35 { ngx_string("POST"), NGX_HTTP_POST }, | |
36 { ngx_string("HEAD"), NGX_HTTP_HEAD }, | |
37 { ngx_string("OPTIONS"), NGX_HTTP_OPTIONS }, | |
38 { ngx_string("PROPFIND"), NGX_HTTP_PROPFIND }, | |
39 { ngx_string("PUT"), NGX_HTTP_PUT }, | |
40 { ngx_string("MKCOL"), NGX_HTTP_MKCOL }, | |
41 { ngx_string("DELETE"), NGX_HTTP_DELETE }, | |
42 { ngx_string("COPY"), NGX_HTTP_COPY }, | |
43 { ngx_string("MOVE"), NGX_HTTP_MOVE }, | |
44 { ngx_string("PROPPATCH"), NGX_HTTP_PROPPATCH }, | |
45 { ngx_string("LOCK"), NGX_HTTP_LOCK }, | |
46 { ngx_string("UNLOCK"), NGX_HTTP_UNLOCK }, | |
47 { ngx_string("PATCH"), NGX_HTTP_PATCH }, | |
48 { ngx_string("TRACE"), NGX_HTTP_TRACE } | |
49 }; | |
50 | |
51 | |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
52 void |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
53 ngx_http_v3_init(ngx_connection_t *c) |
7692
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
54 { |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
55 size_t size; |
8358
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8319
diff
changeset
|
56 uint64_t n; |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
57 ngx_buf_t *b; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
58 ngx_event_t *rev; |
8360
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
59 ngx_pool_cleanup_t *cln; |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
60 ngx_http_request_t *r; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
61 ngx_http_connection_t *hc; |
8430
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8428
diff
changeset
|
62 ngx_http_v3_session_t *h3c; |
8358
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8319
diff
changeset
|
63 ngx_http_core_loc_conf_t *clcf; |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
64 ngx_http_core_srv_conf_t *cscf; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
65 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
66 if (ngx_http_v3_init_session(c) != NGX_OK) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
67 ngx_http_v3_finalize_connection(c, NGX_HTTP_V3_ERR_INTERNAL_ERROR, |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
68 "internal error"); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
69 ngx_http_close_connection(c); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
70 return; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
71 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
72 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
73 if (c->quic->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
74 ngx_http_v3_init_uni_stream(c); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
75 return; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
76 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
77 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
78 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 init request stream"); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
79 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
80 hc = c->data; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
81 |
8358
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8319
diff
changeset
|
82 clcf = ngx_http_get_module_loc_conf(hc->conf_ctx, ngx_http_core_module); |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8319
diff
changeset
|
83 |
8551
c35b255d80dc
HTTP/3: close connection on keepalive_requests * 2.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
84 n = c->quic->id >> 2; |
c35b255d80dc
HTTP/3: close connection on keepalive_requests * 2.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
85 |
c35b255d80dc
HTTP/3: close connection on keepalive_requests * 2.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
86 if (n >= clcf->keepalive_requests * 2) { |
c35b255d80dc
HTTP/3: close connection on keepalive_requests * 2.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
87 ngx_http_v3_finalize_connection(c, NGX_HTTP_V3_ERR_EXCESSIVE_LOAD, |
c35b255d80dc
HTTP/3: close connection on keepalive_requests * 2.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
88 "too many requests per connection"); |
c35b255d80dc
HTTP/3: close connection on keepalive_requests * 2.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
89 ngx_http_close_connection(c); |
c35b255d80dc
HTTP/3: close connection on keepalive_requests * 2.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
90 return; |
c35b255d80dc
HTTP/3: close connection on keepalive_requests * 2.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
91 } |
c35b255d80dc
HTTP/3: close connection on keepalive_requests * 2.
Roman Arutyunyan <arut@nginx.com>
parents:
8508
diff
changeset
|
92 |
8428
40d710a66aef
HTTP/3: ngx_http_v3_get_session() macro.
Roman Arutyunyan <arut@nginx.com>
parents:
8402
diff
changeset
|
93 h3c = ngx_http_v3_get_session(c); |
8358
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8319
diff
changeset
|
94 |
8402
47a43b011dec
HTTP/3: keepalive_time support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8362
diff
changeset
|
95 if (h3c->goaway) { |
8358
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8319
diff
changeset
|
96 ngx_quic_reset_stream(c, NGX_HTTP_V3_ERR_REQUEST_REJECTED); |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8319
diff
changeset
|
97 ngx_http_close_connection(c); |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8319
diff
changeset
|
98 return; |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8319
diff
changeset
|
99 } |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8319
diff
changeset
|
100 |
8402
47a43b011dec
HTTP/3: keepalive_time support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8362
diff
changeset
|
101 if (n + 1 == clcf->keepalive_requests |
47a43b011dec
HTTP/3: keepalive_time support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8362
diff
changeset
|
102 || ngx_current_msec - c->quic->parent->start_time |
47a43b011dec
HTTP/3: keepalive_time support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8362
diff
changeset
|
103 > clcf->keepalive_time) |
47a43b011dec
HTTP/3: keepalive_time support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8362
diff
changeset
|
104 { |
47a43b011dec
HTTP/3: keepalive_time support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8362
diff
changeset
|
105 h3c->goaway = 1; |
47a43b011dec
HTTP/3: keepalive_time support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8362
diff
changeset
|
106 |
8358
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8319
diff
changeset
|
107 if (ngx_http_v3_send_goaway(c, (n + 1) << 2) != NGX_OK) { |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8319
diff
changeset
|
108 ngx_http_v3_finalize_connection(c, NGX_HTTP_V3_ERR_INTERNAL_ERROR, |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8319
diff
changeset
|
109 "goaway error"); |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8319
diff
changeset
|
110 ngx_http_close_connection(c); |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8319
diff
changeset
|
111 return; |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8319
diff
changeset
|
112 } |
8359
fc64ab301bad
QUIC: connection shutdown.
Roman Arutyunyan <arut@nginx.com>
parents:
8358
diff
changeset
|
113 |
fc64ab301bad
QUIC: connection shutdown.
Roman Arutyunyan <arut@nginx.com>
parents:
8358
diff
changeset
|
114 ngx_http_v3_shutdown_connection(c, NGX_HTTP_V3_ERR_NO_ERROR, |
fc64ab301bad
QUIC: connection shutdown.
Roman Arutyunyan <arut@nginx.com>
parents:
8358
diff
changeset
|
115 "reached maximum number of requests"); |
8358
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8319
diff
changeset
|
116 } |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8319
diff
changeset
|
117 |
8360
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
118 cln = ngx_pool_cleanup_add(c->pool, 0); |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
119 if (cln == NULL) { |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
120 ngx_http_close_connection(c); |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
121 return; |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
122 } |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
123 |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
124 cln->handler = ngx_http_v3_cleanup_request; |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
125 cln->data = c; |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
126 |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
127 h3c->nrequests++; |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
128 |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
129 if (h3c->keepalive.timer_set) { |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
130 ngx_del_timer(&h3c->keepalive); |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
131 } |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
132 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
133 cscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_core_module); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
134 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
135 size = cscf->client_header_buffer_size; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
136 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
137 b = c->buffer; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
138 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
139 if (b == NULL) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
140 b = ngx_create_temp_buf(c->pool, size); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
141 if (b == NULL) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
142 ngx_http_close_connection(c); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
143 return; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
144 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
145 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
146 c->buffer = b; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
147 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
148 } else if (b->start == NULL) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
149 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
150 b->start = ngx_palloc(c->pool, size); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
151 if (b->start == NULL) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
152 ngx_http_close_connection(c); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
153 return; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
154 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
155 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
156 b->pos = b->start; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
157 b->last = b->start; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
158 b->end = b->last + size; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
159 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
160 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
161 c->log->action = "reading client request"; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
162 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
163 r = ngx_http_create_request(c); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
164 if (r == NULL) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
165 ngx_http_close_connection(c); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
166 return; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
167 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
168 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
169 r->http_version = NGX_HTTP_VERSION_30; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
170 |
8318
3057bae4dba7
HTTP/3: introduced ngx_http_v3_parse_t structure.
Roman Arutyunyan <arut@nginx.com>
parents:
8283
diff
changeset
|
171 r->v3_parse = ngx_pcalloc(r->pool, sizeof(ngx_http_v3_parse_t)); |
3057bae4dba7
HTTP/3: introduced ngx_http_v3_parse_t structure.
Roman Arutyunyan <arut@nginx.com>
parents:
8283
diff
changeset
|
172 if (r->v3_parse == NULL) { |
3057bae4dba7
HTTP/3: introduced ngx_http_v3_parse_t structure.
Roman Arutyunyan <arut@nginx.com>
parents:
8283
diff
changeset
|
173 ngx_http_close_connection(c); |
3057bae4dba7
HTTP/3: introduced ngx_http_v3_parse_t structure.
Roman Arutyunyan <arut@nginx.com>
parents:
8283
diff
changeset
|
174 return; |
3057bae4dba7
HTTP/3: introduced ngx_http_v3_parse_t structure.
Roman Arutyunyan <arut@nginx.com>
parents:
8283
diff
changeset
|
175 } |
3057bae4dba7
HTTP/3: introduced ngx_http_v3_parse_t structure.
Roman Arutyunyan <arut@nginx.com>
parents:
8283
diff
changeset
|
176 |
8319
ffcaf0aad9f2
HTTP/3: limited client header size.
Roman Arutyunyan <arut@nginx.com>
parents:
8318
diff
changeset
|
177 r->v3_parse->header_limit = cscf->large_client_header_buffers.size |
ffcaf0aad9f2
HTTP/3: limited client header size.
Roman Arutyunyan <arut@nginx.com>
parents:
8318
diff
changeset
|
178 * cscf->large_client_header_buffers.num; |
ffcaf0aad9f2
HTTP/3: limited client header size.
Roman Arutyunyan <arut@nginx.com>
parents:
8318
diff
changeset
|
179 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
180 c->data = r; |
8362
a64255c01dab
HTTP/3: fixed $connection_requests.
Roman Arutyunyan <arut@nginx.com>
parents:
8360
diff
changeset
|
181 c->requests = n + 1; |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
182 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
183 rev = c->read; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
184 rev->handler = ngx_http_v3_process_request; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
185 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
186 ngx_http_v3_process_request(rev); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
187 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
188 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
189 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
190 static void |
8360
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
191 ngx_http_v3_cleanup_request(void *data) |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
192 { |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
193 ngx_connection_t *c = data; |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
194 |
8430
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8428
diff
changeset
|
195 ngx_http_v3_session_t *h3c; |
8360
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
196 ngx_http_core_loc_conf_t *clcf; |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
197 |
8428
40d710a66aef
HTTP/3: ngx_http_v3_get_session() macro.
Roman Arutyunyan <arut@nginx.com>
parents:
8402
diff
changeset
|
198 h3c = ngx_http_v3_get_session(c); |
8360
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
199 |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
200 if (--h3c->nrequests == 0) { |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
201 clcf = ngx_http_v3_get_module_loc_conf(c, ngx_http_core_module); |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
202 ngx_add_timer(&h3c->keepalive, clcf->keepalive_timeout); |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
203 } |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
204 } |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
205 |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
206 |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8359
diff
changeset
|
207 static void |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
208 ngx_http_v3_process_request(ngx_event_t *rev) |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
209 { |
8563
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8560
diff
changeset
|
210 u_char *p; |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
211 ssize_t n; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
212 ngx_buf_t *b; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
213 ngx_int_t rc; |
7692
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
214 ngx_connection_t *c; |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
215 ngx_http_request_t *r; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
216 ngx_http_core_srv_conf_t *cscf; |
7692
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
217 ngx_http_v3_parse_headers_t *st; |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
218 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
219 c = rev->data; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
220 r = c->data; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
221 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
222 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0, "http3 process request"); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
223 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
224 if (rev->timedout) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
225 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
226 c->timedout = 1; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
227 ngx_http_close_request(r, NGX_HTTP_REQUEST_TIME_OUT); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
228 return; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
229 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
230 |
8318
3057bae4dba7
HTTP/3: introduced ngx_http_v3_parse_t structure.
Roman Arutyunyan <arut@nginx.com>
parents:
8283
diff
changeset
|
231 st = &r->v3_parse->headers; |
7692
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
232 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
233 b = r->header_in; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
234 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
235 for ( ;; ) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
236 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
237 if (b->pos == b->last) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
238 |
8278
dbe33ef9cd9a
HTTP/3: call ngx_handle_read_event() from client header handler.
Roman Arutyunyan <arut@nginx.com>
parents:
8275
diff
changeset
|
239 if (rev->ready) { |
dbe33ef9cd9a
HTTP/3: call ngx_handle_read_event() from client header handler.
Roman Arutyunyan <arut@nginx.com>
parents:
8275
diff
changeset
|
240 n = c->recv(c, b->start, b->end - b->start); |
dbe33ef9cd9a
HTTP/3: call ngx_handle_read_event() from client header handler.
Roman Arutyunyan <arut@nginx.com>
parents:
8275
diff
changeset
|
241 |
dbe33ef9cd9a
HTTP/3: call ngx_handle_read_event() from client header handler.
Roman Arutyunyan <arut@nginx.com>
parents:
8275
diff
changeset
|
242 } else { |
dbe33ef9cd9a
HTTP/3: call ngx_handle_read_event() from client header handler.
Roman Arutyunyan <arut@nginx.com>
parents:
8275
diff
changeset
|
243 n = NGX_AGAIN; |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
244 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
245 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
246 if (n == NGX_AGAIN) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
247 if (!rev->timer_set) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
248 cscf = ngx_http_get_module_srv_conf(r, |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
249 ngx_http_core_module); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
250 ngx_add_timer(rev, cscf->client_header_timeout); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
251 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
252 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
253 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
254 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
255 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
256 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
257 break; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
258 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
259 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
260 if (n == 0) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
261 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
262 "client prematurely closed connection"); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
263 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
264 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
265 if (n == 0 || n == NGX_ERROR) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
266 c->error = 1; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
267 c->log->action = "reading client request"; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
268 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
269 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
270 break; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
271 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
272 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
273 b->pos = b->start; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
274 b->last = b->start + n; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
275 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
276 |
8563
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8560
diff
changeset
|
277 p = b->pos; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8560
diff
changeset
|
278 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8560
diff
changeset
|
279 rc = ngx_http_v3_parse_headers(c, st, b); |
7692
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
280 |
7955
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
7951
diff
changeset
|
281 if (rc > 0) { |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
7951
diff
changeset
|
282 ngx_http_v3_finalize_connection(c, rc, |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
7951
diff
changeset
|
283 "could not parse request headers"); |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
284 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
285 break; |
7955
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
7951
diff
changeset
|
286 } |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
7951
diff
changeset
|
287 |
7692
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
288 if (rc == NGX_ERROR) { |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
289 ngx_http_v3_finalize_connection(c, NGX_HTTP_V3_ERR_INTERNAL_ERROR, |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
290 "internal error"); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
291 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
292 break; |
7692
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
293 } |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
294 |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7947
diff
changeset
|
295 if (rc == NGX_BUSY) { |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
296 if (rev->error) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
297 ngx_http_close_request(r, NGX_HTTP_CLOSE); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
298 break; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
299 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
300 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
301 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
302 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
303 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
304 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
305 break; |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7947
diff
changeset
|
306 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7947
diff
changeset
|
307 |
8563
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8560
diff
changeset
|
308 r->request_length += b->pos - p; |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7947
diff
changeset
|
309 |
7692
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
310 if (rc == NGX_AGAIN) { |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
311 continue; |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
312 } |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
313 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
314 /* rc == NGX_OK || rc == NGX_DONE */ |
7699
1e45c02f6376
HTTP/3 $request_line variable.
Roman Arutyunyan <arut@nginx.com>
parents:
7696
diff
changeset
|
315 |
8508
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8430
diff
changeset
|
316 if (ngx_http_v3_process_header(r, &st->field_rep.field.name, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8430
diff
changeset
|
317 &st->field_rep.field.value) |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
318 != NGX_OK) |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
319 { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
320 break; |
7882
d2759e4cc437
HTTP/3: split header parser in two functions.
Roman Arutyunyan <arut@nginx.com>
parents:
7871
diff
changeset
|
321 } |
7692
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
322 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
323 if (rc == NGX_DONE) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
324 if (ngx_http_v3_process_request_header(r) != NGX_OK) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
325 break; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
326 } |
7882
d2759e4cc437
HTTP/3: split header parser in two functions.
Roman Arutyunyan <arut@nginx.com>
parents:
7871
diff
changeset
|
327 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
328 ngx_http_process_request(r); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
329 break; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
330 } |
7692
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
331 } |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
332 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
333 ngx_http_run_posted_requests(c); |
7692
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
334 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
335 return; |
7882
d2759e4cc437
HTTP/3: split header parser in two functions.
Roman Arutyunyan <arut@nginx.com>
parents:
7871
diff
changeset
|
336 } |
d2759e4cc437
HTTP/3: split header parser in two functions.
Roman Arutyunyan <arut@nginx.com>
parents:
7871
diff
changeset
|
337 |
d2759e4cc437
HTTP/3: split header parser in two functions.
Roman Arutyunyan <arut@nginx.com>
parents:
7871
diff
changeset
|
338 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
339 static ngx_int_t |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
340 ngx_http_v3_process_header(ngx_http_request_t *r, ngx_str_t *name, |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
341 ngx_str_t *value) |
7882
d2759e4cc437
HTTP/3: split header parser in two functions.
Roman Arutyunyan <arut@nginx.com>
parents:
7871
diff
changeset
|
342 { |
8319
ffcaf0aad9f2
HTTP/3: limited client header size.
Roman Arutyunyan <arut@nginx.com>
parents:
8318
diff
changeset
|
343 size_t len; |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
344 ngx_table_elt_t *h; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
345 ngx_http_header_t *hh; |
8275
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
346 ngx_http_core_srv_conf_t *cscf; |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
347 ngx_http_core_main_conf_t *cmcf; |
7947
a6675a976560
HTTP/3: fixed dropping first non-pseudo header.
Roman Arutyunyan <arut@nginx.com>
parents:
7946
diff
changeset
|
348 |
8319
ffcaf0aad9f2
HTTP/3: limited client header size.
Roman Arutyunyan <arut@nginx.com>
parents:
8318
diff
changeset
|
349 len = name->len + value->len; |
ffcaf0aad9f2
HTTP/3: limited client header size.
Roman Arutyunyan <arut@nginx.com>
parents:
8318
diff
changeset
|
350 |
ffcaf0aad9f2
HTTP/3: limited client header size.
Roman Arutyunyan <arut@nginx.com>
parents:
8318
diff
changeset
|
351 if (len > r->v3_parse->header_limit) { |
ffcaf0aad9f2
HTTP/3: limited client header size.
Roman Arutyunyan <arut@nginx.com>
parents:
8318
diff
changeset
|
352 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
ffcaf0aad9f2
HTTP/3: limited client header size.
Roman Arutyunyan <arut@nginx.com>
parents:
8318
diff
changeset
|
353 "client sent too large header"); |
ffcaf0aad9f2
HTTP/3: limited client header size.
Roman Arutyunyan <arut@nginx.com>
parents:
8318
diff
changeset
|
354 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_HEADER_TOO_LARGE); |
ffcaf0aad9f2
HTTP/3: limited client header size.
Roman Arutyunyan <arut@nginx.com>
parents:
8318
diff
changeset
|
355 return NGX_ERROR; |
ffcaf0aad9f2
HTTP/3: limited client header size.
Roman Arutyunyan <arut@nginx.com>
parents:
8318
diff
changeset
|
356 } |
ffcaf0aad9f2
HTTP/3: limited client header size.
Roman Arutyunyan <arut@nginx.com>
parents:
8318
diff
changeset
|
357 |
ffcaf0aad9f2
HTTP/3: limited client header size.
Roman Arutyunyan <arut@nginx.com>
parents:
8318
diff
changeset
|
358 r->v3_parse->header_limit -= len; |
ffcaf0aad9f2
HTTP/3: limited client header size.
Roman Arutyunyan <arut@nginx.com>
parents:
8318
diff
changeset
|
359 |
8275
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
360 if (ngx_http_v3_validate_header(r, name, value) != NGX_OK) { |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
361 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
362 return NGX_ERROR; |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
363 } |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
364 |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
365 if (r->invalid_header) { |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
366 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
367 |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
368 if (cscf->ignore_invalid_headers) { |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
369 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
370 "client sent invalid header: \"%V\"", name); |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
371 |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
372 return NGX_OK; |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
373 } |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
374 } |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
375 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
376 if (name->len && name->data[0] == ':') { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
377 return ngx_http_v3_process_pseudo_header(r, name, value); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
378 } |
7947
a6675a976560
HTTP/3: fixed dropping first non-pseudo header.
Roman Arutyunyan <arut@nginx.com>
parents:
7946
diff
changeset
|
379 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
380 if (ngx_http_v3_init_pseudo_headers(r) != NGX_OK) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
381 return NGX_ERROR; |
7882
d2759e4cc437
HTTP/3: split header parser in two functions.
Roman Arutyunyan <arut@nginx.com>
parents:
7871
diff
changeset
|
382 } |
d2759e4cc437
HTTP/3: split header parser in two functions.
Roman Arutyunyan <arut@nginx.com>
parents:
7871
diff
changeset
|
383 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
384 h = ngx_list_push(&r->headers_in.headers); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
385 if (h == NULL) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
386 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
387 return NGX_ERROR; |
7882
d2759e4cc437
HTTP/3: split header parser in two functions.
Roman Arutyunyan <arut@nginx.com>
parents:
7871
diff
changeset
|
388 } |
d2759e4cc437
HTTP/3: split header parser in two functions.
Roman Arutyunyan <arut@nginx.com>
parents:
7871
diff
changeset
|
389 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
390 h->key = *name; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
391 h->value = *value; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
392 h->lowcase_key = h->key.data; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
393 h->hash = ngx_hash_key(h->key.data, h->key.len); |
7883
66feab03d9b7
HTTP/3: restricted symbols in header names.
Roman Arutyunyan <arut@nginx.com>
parents:
7882
diff
changeset
|
394 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
395 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); |
7882
d2759e4cc437
HTTP/3: split header parser in two functions.
Roman Arutyunyan <arut@nginx.com>
parents:
7871
diff
changeset
|
396 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
397 hh = ngx_hash_find(&cmcf->headers_in_hash, h->hash, |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
398 h->lowcase_key, h->key.len); |
7883
66feab03d9b7
HTTP/3: restricted symbols in header names.
Roman Arutyunyan <arut@nginx.com>
parents:
7882
diff
changeset
|
399 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
400 if (hh && hh->handler(r, h, hh->offset) != NGX_OK) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
401 return NGX_ERROR; |
7883
66feab03d9b7
HTTP/3: restricted symbols in header names.
Roman Arutyunyan <arut@nginx.com>
parents:
7882
diff
changeset
|
402 } |
66feab03d9b7
HTTP/3: restricted symbols in header names.
Roman Arutyunyan <arut@nginx.com>
parents:
7882
diff
changeset
|
403 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
404 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
405 "http3 header: \"%V: %V\"", name, value); |
7882
d2759e4cc437
HTTP/3: split header parser in two functions.
Roman Arutyunyan <arut@nginx.com>
parents:
7871
diff
changeset
|
406 return NGX_OK; |
7692
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
407 } |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
408 |
7681 | 409 |
410 static ngx_int_t | |
8275
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
411 ngx_http_v3_validate_header(ngx_http_request_t *r, ngx_str_t *name, |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
412 ngx_str_t *value) |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
413 { |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
414 u_char ch; |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
415 ngx_uint_t i; |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
416 ngx_http_core_srv_conf_t *cscf; |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
417 |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
418 r->invalid_header = 0; |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
419 |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
420 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
421 |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
422 for (i = (name->data[0] == ':'); i != name->len; i++) { |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
423 ch = name->data[i]; |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
424 |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
425 if ((ch >= 'a' && ch <= 'z') |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
426 || (ch == '-') |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
427 || (ch >= '0' && ch <= '9') |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
428 || (ch == '_' && cscf->underscores_in_headers)) |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
429 { |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
430 continue; |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
431 } |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
432 |
8557
0d35b1ff6af5
HTTP/3: disabled control characters and space in header names.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8551
diff
changeset
|
433 if (ch <= 0x20 || ch == 0x7f || ch == ':' |
8275
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
434 || (ch >= 'A' && ch <= 'Z')) |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
435 { |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
436 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
437 "client sent invalid header name: \"%V\"", name); |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
438 |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
439 return NGX_ERROR; |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
440 } |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
441 |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
442 r->invalid_header = 1; |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
443 } |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
444 |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
445 for (i = 0; i != value->len; i++) { |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
446 ch = value->data[i]; |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
447 |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
448 if (ch == '\0' || ch == LF || ch == CR) { |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
449 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
450 "client sent header \"%V\" with " |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
451 "invalid value: \"%V\"", name, value); |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
452 |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
453 return NGX_ERROR; |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
454 } |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
455 } |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
456 |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
457 return NGX_OK; |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
458 } |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
459 |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
460 |
916a2e1d6617
HTTP/3: client header validation.
Roman Arutyunyan <arut@nginx.com>
parents:
8273
diff
changeset
|
461 static ngx_int_t |
7681 | 462 ngx_http_v3_process_pseudo_header(ngx_http_request_t *r, ngx_str_t *name, |
463 ngx_str_t *value) | |
464 { | |
8273
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
465 u_char ch, c; |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
466 ngx_uint_t i; |
7681 | 467 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
468 if (r->request_line.len) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
469 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
470 "client sent out of order pseudo-headers"); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
471 goto failed; |
7692
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
472 } |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
473 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
474 if (name->len == 7 && ngx_strncmp(name->data, ":method", 7) == 0) { |
7681 | 475 |
8273
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
476 if (r->method_name.len) { |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
477 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
478 "client sent duplicate \":method\" header"); |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
479 goto failed; |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
480 } |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
481 |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
482 if (value->len == 0) { |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
483 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
484 "client sent empty \":method\" header"); |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
485 goto failed; |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
486 } |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
487 |
8234
9dce2978e4fd
HTTP/3: eliminated r->method_start.
Roman Arutyunyan <arut@nginx.com>
parents:
8200
diff
changeset
|
488 r->method_name = *value; |
7681 | 489 |
490 for (i = 0; i < sizeof(ngx_http_v3_methods) | |
491 / sizeof(ngx_http_v3_methods[0]); i++) | |
492 { | |
493 if (value->len == ngx_http_v3_methods[i].name.len | |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
494 && ngx_strncmp(value->data, |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
495 ngx_http_v3_methods[i].name.data, value->len) |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
496 == 0) |
7681 | 497 { |
498 r->method = ngx_http_v3_methods[i].method; | |
499 break; | |
500 } | |
501 } | |
502 | |
8273
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
503 for (i = 0; i < value->len; i++) { |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
504 ch = value->data[i]; |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
505 |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
506 if ((ch < 'A' || ch > 'Z') && ch != '_' && ch != '-') { |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
507 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
508 "client sent invalid method: \"%V\"", value); |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
509 goto failed; |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
510 } |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
511 } |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
512 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
513 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
7681 | 514 "http3 method \"%V\" %ui", value, r->method); |
515 return NGX_OK; | |
516 } | |
517 | |
518 if (name->len == 5 && ngx_strncmp(name->data, ":path", 5) == 0) { | |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
519 |
8273
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
520 if (r->uri_start) { |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
521 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
522 "client sent duplicate \":path\" header"); |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
523 goto failed; |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
524 } |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
525 |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
526 if (value->len == 0) { |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
527 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
528 "client sent empty \":path\" header"); |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
529 goto failed; |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
530 } |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
531 |
7681 | 532 r->uri_start = value->data; |
533 r->uri_end = value->data + value->len; | |
534 | |
535 if (ngx_http_parse_uri(r) != NGX_OK) { | |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
536 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
537 "client sent invalid \":path\" header: \"%V\"", |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
538 value); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
539 goto failed; |
7681 | 540 } |
541 | |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
542 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
7681 | 543 "http3 path \"%V\"", value); |
544 return NGX_OK; | |
545 } | |
546 | |
547 if (name->len == 7 && ngx_strncmp(name->data, ":scheme", 7) == 0) { | |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
548 |
8273
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
549 if (r->schema.len) { |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
550 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
551 "client sent duplicate \":scheme\" header"); |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
552 goto failed; |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
553 } |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
554 |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
555 if (value->len == 0) { |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
556 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
557 "client sent empty \":scheme\" header"); |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
558 goto failed; |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
559 } |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
560 |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
561 for (i = 0; i < value->len; i++) { |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
562 ch = value->data[i]; |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
563 |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
564 c = (u_char) (ch | 0x20); |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
565 if (c >= 'a' && c <= 'z') { |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
566 continue; |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
567 } |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
568 |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
569 if (((ch >= '0' && ch <= '9') |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
570 || ch == '+' || ch == '-' || ch == '.') |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
571 && i > 0) |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
572 { |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
573 continue; |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
574 } |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
575 |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
576 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
577 "client sent invalid \":scheme\" header: \"%V\"", |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
578 value); |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
579 goto failed; |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
580 } |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
581 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
582 r->schema = *value; |
7681 | 583 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
584 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
7681 | 585 "http3 schema \"%V\"", value); |
586 return NGX_OK; | |
587 } | |
588 | |
589 if (name->len == 10 && ngx_strncmp(name->data, ":authority", 10) == 0) { | |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
590 |
8273
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
591 if (r->host_start) { |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
592 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
593 "client sent duplicate \":authority\" header"); |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
594 goto failed; |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
595 } |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
596 |
7681 | 597 r->host_start = value->data; |
598 r->host_end = value->data + value->len; | |
599 | |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
600 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
7681 | 601 "http3 authority \"%V\"", value); |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
602 return NGX_OK; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
603 } |
7681 | 604 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
605 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
606 "client sent unknown pseudo-header \"%V\"", name); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
607 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
608 failed: |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
609 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
610 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
611 return NGX_ERROR; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
612 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
613 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
614 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
615 static ngx_int_t |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
616 ngx_http_v3_init_pseudo_headers(ngx_http_request_t *r) |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
617 { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
618 size_t len; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
619 u_char *p; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
620 ngx_int_t rc; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
621 ngx_str_t host; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
622 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
623 if (r->request_line.len) { |
7681 | 624 return NGX_OK; |
625 } | |
626 | |
8273
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
627 if (r->method_name.len == 0) { |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
628 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
629 "client sent no \":method\" header"); |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
630 goto failed; |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
631 } |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
632 |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
633 if (r->schema.len == 0) { |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
634 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
635 "client sent no \":scheme\" header"); |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
636 goto failed; |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
637 } |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
638 |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
639 if (r->uri_start == NULL) { |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
640 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
641 "client sent no \":path\" header"); |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
642 goto failed; |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
643 } |
58acdba9b3b2
HTTP/3: client pseudo-headers restrictions.
Roman Arutyunyan <arut@nginx.com>
parents:
8272
diff
changeset
|
644 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
645 len = r->method_name.len + 1 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
646 + (r->uri_end - r->uri_start) + 1 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
647 + sizeof("HTTP/3.0") - 1; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
648 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
649 p = ngx_pnalloc(r->pool, len); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
650 if (p == NULL) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
651 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
652 return NGX_ERROR; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
653 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
654 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
655 r->request_line.data = p; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
656 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
657 p = ngx_cpymem(p, r->method_name.data, r->method_name.len); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
658 *p++ = ' '; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
659 p = ngx_cpymem(p, r->uri_start, r->uri_end - r->uri_start); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
660 *p++ = ' '; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
661 p = ngx_cpymem(p, "HTTP/3.0", sizeof("HTTP/3.0") - 1); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
662 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
663 r->request_line.len = p - r->request_line.data; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
664 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
665 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
666 "http3 request line: \"%V\"", &r->request_line); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
667 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
668 ngx_str_set(&r->http_protocol, "HTTP/3.0"); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
669 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
670 if (ngx_http_process_request_uri(r) != NGX_OK) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
671 return NGX_ERROR; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
672 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
673 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
674 if (r->host_end) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
675 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
676 host.len = r->host_end - r->host_start; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
677 host.data = r->host_start; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
678 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
679 rc = ngx_http_validate_host(&host, r->pool, 0); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
680 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
681 if (rc == NGX_DECLINED) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
682 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
683 "client sent invalid host in request line"); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
684 goto failed; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
685 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
686 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
687 if (rc == NGX_ERROR) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
688 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
689 return NGX_ERROR; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
690 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
691 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
692 if (ngx_http_set_virtual_server(r, &host) == NGX_ERROR) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
693 return NGX_ERROR; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
694 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
695 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
696 r->headers_in.server = host; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
697 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
698 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
699 if (ngx_list_init(&r->headers_in.headers, r->pool, 20, |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
700 sizeof(ngx_table_elt_t)) |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
701 != NGX_OK) |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
702 { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
703 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
704 return NGX_ERROR; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
705 } |
7681 | 706 |
7692
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7685
diff
changeset
|
707 return NGX_OK; |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
708 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
709 failed: |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
710 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
711 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
712 return NGX_ERROR; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
713 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
714 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
715 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
716 static ngx_int_t |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
717 ngx_http_v3_process_request_header(ngx_http_request_t *r) |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
718 { |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
719 ssize_t n; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
720 ngx_buf_t *b; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
721 ngx_connection_t *c; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
722 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
723 c = r->connection; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
724 |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
725 if (ngx_http_v3_init_pseudo_headers(r) != NGX_OK) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
726 return NGX_ERROR; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
727 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
728 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
729 if (r->headers_in.server.len == 0) { |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
730 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
731 "client sent neither \":authority\" nor \"Host\" header"); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
732 goto failed; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
733 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
734 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
735 if (r->headers_in.host) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
736 if (r->headers_in.host->value.len != r->headers_in.server.len |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
737 || ngx_memcmp(r->headers_in.host->value.data, |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
738 r->headers_in.server.data, |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
739 r->headers_in.server.len) |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
740 != 0) |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
741 { |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
742 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
743 "client sent \":authority\" and \"Host\" headers " |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
744 "with different values"); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
745 goto failed; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
746 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
747 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
748 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
749 if (r->headers_in.content_length) { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
750 r->headers_in.content_length_n = |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
751 ngx_atoof(r->headers_in.content_length->value.data, |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
752 r->headers_in.content_length->value.len); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
753 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
754 if (r->headers_in.content_length_n == NGX_ERROR) { |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
755 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
756 "client sent invalid \"Content-Length\" header"); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
757 goto failed; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
758 } |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
759 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
760 } else { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
761 b = r->header_in; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
762 n = b->last - b->pos; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
763 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
764 if (n == 0) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
765 n = c->recv(c, b->start, b->end - b->start); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
766 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
767 if (n == NGX_ERROR) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
768 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
769 return NGX_ERROR; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
770 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
771 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
772 if (n > 0) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
773 b->pos = b->start; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
774 b->last = b->start + n; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
775 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
776 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
777 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
778 if (n != 0) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
779 r->headers_in.chunked = 1; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
780 } |
8272
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
781 } |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
782 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
783 return NGX_OK; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
784 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
785 failed: |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
786 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
787 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8258
diff
changeset
|
788 return NGX_ERROR; |
7681 | 789 } |
790 | |
791 | |
7761
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
792 ngx_int_t |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
793 ngx_http_v3_read_request_body(ngx_http_request_t *r) |
7761
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
794 { |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
795 size_t preread; |
7761
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
796 ngx_int_t rc; |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
797 ngx_chain_t *cl, out; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
798 ngx_http_request_body_t *rb; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
799 ngx_http_core_loc_conf_t *clcf; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
800 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
801 rb = r->request_body; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
802 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
803 preread = r->header_in->last - r->header_in->pos; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
804 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
805 if (preread) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
806 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
807 /* there is the pre-read part of the request body */ |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
808 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
809 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
810 "http3 client request body preread %uz", preread); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
811 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
812 out.buf = r->header_in; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
813 out.next = NULL; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
814 cl = &out; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
815 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
816 } else { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
817 cl = NULL; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
818 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
819 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
820 rc = ngx_http_v3_request_body_filter(r, cl); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
821 if (rc != NGX_OK) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
822 return rc; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
823 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
824 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
825 if (rb->rest == 0) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
826 /* the whole request body was pre-read */ |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
827 r->request_body_no_buffering = 0; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
828 rb->post_handler(r); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
829 return NGX_OK; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
830 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
831 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
832 if (rb->rest < 0) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
833 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
834 "negative request body rest"); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
835 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
836 } |
7761
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
837 |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
838 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
839 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
840 rb->buf = ngx_create_temp_buf(r->pool, clcf->client_body_buffer_size); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
841 if (rb->buf == NULL) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
842 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
843 } |
7761
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
844 |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
845 r->read_event_handler = ngx_http_v3_read_client_request_body_handler; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
846 r->write_event_handler = ngx_http_request_empty_handler; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
847 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
848 return ngx_http_v3_do_read_client_request_body(r); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
849 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
850 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
851 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
852 static void |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
853 ngx_http_v3_read_client_request_body_handler(ngx_http_request_t *r) |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
854 { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
855 ngx_int_t rc; |
7761
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
856 |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
857 if (r->connection->read->timedout) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
858 r->connection->timedout = 1; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
859 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_TIME_OUT); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
860 return; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
861 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
862 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
863 rc = ngx_http_v3_do_read_client_request_body(r); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
864 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
865 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
866 ngx_http_finalize_request(r, rc); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
867 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
868 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
869 |
7761
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
870 |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
871 ngx_int_t |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
872 ngx_http_v3_read_unbuffered_request_body(ngx_http_request_t *r) |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
873 { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
874 ngx_int_t rc; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
875 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
876 if (r->connection->read->timedout) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
877 r->connection->timedout = 1; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
878 return NGX_HTTP_REQUEST_TIME_OUT; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
879 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
880 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
881 rc = ngx_http_v3_do_read_client_request_body(r); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
882 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
883 if (rc == NGX_OK) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
884 r->reading_body = 0; |
7761
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
885 } |
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
886 |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
887 return rc; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
888 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
889 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
890 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
891 static ngx_int_t |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
892 ngx_http_v3_do_read_client_request_body(ngx_http_request_t *r) |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
893 { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
894 off_t rest; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
895 size_t size; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
896 ssize_t n; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
897 ngx_int_t rc; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
898 ngx_chain_t out; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
899 ngx_connection_t *c; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
900 ngx_http_request_body_t *rb; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
901 ngx_http_core_loc_conf_t *clcf; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
902 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
903 c = r->connection; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
904 rb = r->request_body; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
905 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
906 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
907 "http3 read client request body"); |
7761
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
908 |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
909 for ( ;; ) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
910 for ( ;; ) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
911 if (rb->buf->last == rb->buf->end) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
912 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
913 /* update chains */ |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
914 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
915 rc = ngx_http_v3_request_body_filter(r, NULL); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
916 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
917 if (rc != NGX_OK) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
918 return rc; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
919 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
920 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
921 if (rb->busy != NULL) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
922 if (r->request_body_no_buffering) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
923 if (c->read->timer_set) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
924 ngx_del_timer(c->read); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
925 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
926 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
927 if (ngx_handle_read_event(c->read, 0) != NGX_OK) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
928 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
929 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
930 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
931 return NGX_AGAIN; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
932 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
933 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
934 ngx_log_error(NGX_LOG_ALERT, c->log, 0, |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
935 "busy buffers after request body flush"); |
7761
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
936 |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
937 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
938 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
939 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
940 rb->buf->pos = rb->buf->start; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
941 rb->buf->last = rb->buf->start; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
942 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
943 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
944 size = rb->buf->end - rb->buf->last; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
945 rest = rb->rest - (rb->buf->last - rb->buf->pos); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
946 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
947 if ((off_t) size > rest) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
948 size = (size_t) rest; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
949 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
950 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
951 n = c->recv(c, rb->buf->last, size); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
952 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
953 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
954 "http3 client request body recv %z", n); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
955 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
956 if (n == NGX_AGAIN) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
957 break; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
958 } |
7955
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
7951
diff
changeset
|
959 |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
960 if (n == 0) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
961 rb->buf->last_buf = 1; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
962 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
963 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
964 if (n == NGX_ERROR) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
965 c->error = 1; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
966 return NGX_HTTP_BAD_REQUEST; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
967 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
968 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
969 rb->buf->last += n; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
970 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
971 /* pass buffer to request body filter chain */ |
7761
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
972 |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
973 out.buf = rb->buf; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
974 out.next = NULL; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
975 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
976 rc = ngx_http_v3_request_body_filter(r, &out); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
977 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
978 if (rc != NGX_OK) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
979 return rc; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
980 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
981 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
982 if (rb->rest == 0) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
983 break; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
984 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
985 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
986 if (rb->buf->last < rb->buf->end) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
987 break; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
988 } |
7761
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
989 } |
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
990 |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
991 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
992 "http3 client request body rest %O", rb->rest); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
993 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
994 if (rb->rest == 0) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
995 break; |
8087
d70a38acaea0
HTTP/3: skip unknown frames on request stream.
Roman Arutyunyan <arut@nginx.com>
parents:
8086
diff
changeset
|
996 } |
d70a38acaea0
HTTP/3: skip unknown frames on request stream.
Roman Arutyunyan <arut@nginx.com>
parents:
8086
diff
changeset
|
997 |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
998 if (!c->read->ready) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
999 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1000 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1001 ngx_add_timer(c->read, clcf->client_body_timeout); |
7761
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
1002 |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1003 if (ngx_handle_read_event(c->read, 0) != NGX_OK) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1004 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1005 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1006 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1007 return NGX_AGAIN; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1008 } |
7761
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
1009 } |
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
1010 |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1011 if (c->read->timer_set) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1012 ngx_del_timer(c->read); |
7761
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
1013 } |
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
1014 |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1015 if (!r->request_body_no_buffering) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1016 r->read_event_handler = ngx_http_block_reading; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1017 rb->post_handler(r); |
7761
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
1018 } |
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
1019 |
8086
9ffef6054abf
HTTP/3: fixed handling request body eof.
Roman Arutyunyan <arut@nginx.com>
parents:
8049
diff
changeset
|
1020 return NGX_OK; |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1021 } |
7761
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
1022 |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1023 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1024 static ngx_int_t |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1025 ngx_http_v3_request_body_filter(ngx_http_request_t *r, ngx_chain_t *in) |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1026 { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1027 off_t max; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1028 size_t size; |
8563
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8560
diff
changeset
|
1029 u_char *p; |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1030 ngx_int_t rc; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1031 ngx_buf_t *b; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1032 ngx_uint_t last; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1033 ngx_chain_t *cl, *out, *tl, **ll; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1034 ngx_http_request_body_t *rb; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1035 ngx_http_core_loc_conf_t *clcf; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1036 ngx_http_core_srv_conf_t *cscf; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1037 ngx_http_v3_parse_data_t *st; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1038 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1039 rb = r->request_body; |
8318
3057bae4dba7
HTTP/3: introduced ngx_http_v3_parse_t structure.
Roman Arutyunyan <arut@nginx.com>
parents:
8283
diff
changeset
|
1040 st = &r->v3_parse->body; |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1041 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1042 if (rb->rest == -1) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1043 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1044 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1045 "http3 request body filter"); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1046 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1047 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1048 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1049 rb->rest = cscf->large_client_header_buffers.size; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1050 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1051 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1052 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1053 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1054 max = r->headers_in.content_length_n; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1055 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1056 if (max == -1 && clcf->client_max_body_size) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1057 max = clcf->client_max_body_size; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1058 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1059 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1060 out = NULL; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1061 ll = &out; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1062 last = 0; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1063 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1064 for (cl = in; cl; cl = cl->next) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1065 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1066 ngx_log_debug7(NGX_LOG_DEBUG_EVENT, r->connection->log, 0, |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1067 "http3 body buf " |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1068 "t:%d f:%d %p, pos %p, size: %z file: %O, size: %O", |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1069 cl->buf->temporary, cl->buf->in_file, |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1070 cl->buf->start, cl->buf->pos, |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1071 cl->buf->last - cl->buf->pos, |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1072 cl->buf->file_pos, |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1073 cl->buf->file_last - cl->buf->file_pos); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1074 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1075 if (cl->buf->last_buf) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1076 last = 1; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1077 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1078 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1079 b = NULL; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1080 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1081 while (cl->buf->pos < cl->buf->last) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1082 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1083 if (st->length == 0) { |
8563
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8560
diff
changeset
|
1084 p = cl->buf->pos; |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1085 |
8563
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8560
diff
changeset
|
1086 rc = ngx_http_v3_parse_data(r->connection, st, cl->buf); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8560
diff
changeset
|
1087 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8560
diff
changeset
|
1088 r->request_length += cl->buf->pos - p; |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1089 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1090 if (rc == NGX_AGAIN) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1091 continue; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1092 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1093 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1094 if (rc == NGX_DONE) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1095 last = 1; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1096 goto done; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1097 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1098 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1099 if (rc > 0) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1100 ngx_http_v3_finalize_connection(r->connection, rc, |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1101 "client sent invalid body"); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1102 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1103 "client sent invalid body"); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1104 return NGX_HTTP_BAD_REQUEST; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1105 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1106 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1107 if (rc == NGX_ERROR) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1108 ngx_http_v3_finalize_connection(r->connection, |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1109 NGX_HTTP_V3_ERR_INTERNAL_ERROR, |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1110 "internal error"); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1111 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1112 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1113 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1114 /* rc == NGX_OK */ |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1115 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1116 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1117 if (max != -1 && (uint64_t) (max - rb->received) < st->length) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1118 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1119 "client intended to send too large " |
8283
a9034b10dacc
HTTP/3: fixed format specifier.
Roman Arutyunyan <arut@nginx.com>
parents:
8282
diff
changeset
|
1120 "body: %O+%ui bytes", |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1121 rb->received, st->length); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1122 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1123 return NGX_HTTP_REQUEST_ENTITY_TOO_LARGE; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1124 } |
7761
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
1125 |
8282
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1126 if (b |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1127 && st->length <= 128 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1128 && (uint64_t) (cl->buf->last - cl->buf->pos) >= st->length) |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1129 { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1130 rb->received += st->length; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1131 r->request_length += st->length; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1132 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1133 if (st->length < 8) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1134 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1135 while (st->length) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1136 *b->last++ = *cl->buf->pos++; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1137 st->length--; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1138 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1139 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1140 } else { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1141 ngx_memmove(b->last, cl->buf->pos, st->length); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1142 b->last += st->length; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1143 cl->buf->pos += st->length; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1144 st->length = 0; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1145 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1146 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1147 continue; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1148 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1149 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1150 tl = ngx_chain_get_free_buf(r->pool, &rb->free); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1151 if (tl == NULL) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1152 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1153 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1154 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1155 b = tl->buf; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1156 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1157 ngx_memzero(b, sizeof(ngx_buf_t)); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1158 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1159 b->temporary = 1; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1160 b->tag = (ngx_buf_tag_t) &ngx_http_read_client_request_body; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1161 b->start = cl->buf->pos; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1162 b->pos = cl->buf->pos; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1163 b->last = cl->buf->last; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1164 b->end = cl->buf->end; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1165 b->flush = r->request_body_no_buffering; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1166 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1167 *ll = tl; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1168 ll = &tl->next; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1169 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1170 size = cl->buf->last - cl->buf->pos; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1171 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1172 if (size > st->length) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1173 cl->buf->pos += (size_t) st->length; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1174 rb->received += st->length; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1175 r->request_length += st->length; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1176 st->length = 0; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1177 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1178 } else { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1179 st->length -= size; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1180 rb->received += size; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1181 r->request_length += size; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1182 cl->buf->pos = cl->buf->last; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1183 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1184 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1185 b->last = cl->buf->pos; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1186 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1187 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1188 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1189 done: |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1190 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1191 if (last) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1192 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1193 if (st->length > 0) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1194 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1195 "client prematurely closed stream"); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1196 r->connection->error = 1; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1197 return NGX_HTTP_BAD_REQUEST; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1198 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1199 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1200 if (r->headers_in.content_length_n == -1) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1201 r->headers_in.content_length_n = rb->received; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1202 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1203 } else if (r->headers_in.content_length_n != rb->received) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1204 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1205 "client sent less body data than expected: " |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1206 "%O out of %O bytes of request body received", |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1207 rb->received, r->headers_in.content_length_n); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1208 return NGX_HTTP_BAD_REQUEST; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1209 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1210 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1211 rb->rest = 0; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1212 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1213 tl = ngx_chain_get_free_buf(r->pool, &rb->free); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1214 if (tl == NULL) { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1215 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1216 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1217 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1218 b = tl->buf; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1219 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1220 ngx_memzero(b, sizeof(ngx_buf_t)); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1221 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1222 b->last_buf = 1; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1223 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1224 *ll = tl; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1225 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1226 } else { |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1227 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1228 /* set rb->rest, amount of data we want to see next time */ |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1229 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1230 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1231 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1232 rb->rest = (off_t) cscf->large_client_header_buffers.size; |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1233 } |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1234 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1235 rc = ngx_http_top_request_body_filter(r, out); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1236 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1237 ngx_chain_update_chains(r->pool, &rb->free, &rb->busy, &out, |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1238 (ngx_buf_tag_t) &ngx_http_read_client_request_body); |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1239 |
6bd8ed493b85
HTTP/3: refactored request body parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8278
diff
changeset
|
1240 return rc; |
7761
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
7758
diff
changeset
|
1241 } |