Mercurial > hg > nginx
annotate src/http/v3/ngx_http_v3_parse.c @ 9320:cf73b65983c2 default tip
release-1.27.3 tag
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 13 Aug 2024 17:26:33 +0300 |
parents | 4c7a9355bcae |
children |
rev | line source |
---|---|
8226 | 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 | |
8550
234e9d89ff7f
HTTP/3: reject HTTP/2 frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8549
diff
changeset
|
13 #define ngx_http_v3_is_v2_frame(type) \ |
234e9d89ff7f
HTTP/3: reject HTTP/2 frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8549
diff
changeset
|
14 ((type) == 0x02 || (type) == 0x06 || (type) == 0x08 || (type) == 0x09) |
234e9d89ff7f
HTTP/3: reject HTTP/2 frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8549
diff
changeset
|
15 |
234e9d89ff7f
HTTP/3: reject HTTP/2 frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8549
diff
changeset
|
16 |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
17 static void ngx_http_v3_parse_start_local(ngx_buf_t *b, ngx_buf_t *loc, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
18 ngx_uint_t n); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
19 static void ngx_http_v3_parse_end_local(ngx_buf_t *b, ngx_buf_t *loc, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
20 ngx_uint_t *n); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
21 static ngx_int_t ngx_http_v3_parse_skip(ngx_buf_t *b, ngx_uint_t *length); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
22 |
8666
ab6aaa8e86b0
HTTP/3: staticize internal parsing functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8649
diff
changeset
|
23 static ngx_int_t ngx_http_v3_parse_varlen_int(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
24 ngx_http_v3_parse_varlen_int_t *st, ngx_buf_t *b); |
8666
ab6aaa8e86b0
HTTP/3: staticize internal parsing functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8649
diff
changeset
|
25 static ngx_int_t ngx_http_v3_parse_prefix_int(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
26 ngx_http_v3_parse_prefix_int_t *st, ngx_uint_t prefix, ngx_buf_t *b); |
8666
ab6aaa8e86b0
HTTP/3: staticize internal parsing functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8649
diff
changeset
|
27 |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
28 static ngx_int_t ngx_http_v3_parse_field_section_prefix(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
29 ngx_http_v3_parse_field_section_prefix_t *st, ngx_buf_t *b); |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
30 static ngx_int_t ngx_http_v3_parse_field_rep(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
31 ngx_http_v3_parse_field_rep_t *st, ngx_uint_t base, ngx_buf_t *b); |
8666
ab6aaa8e86b0
HTTP/3: staticize internal parsing functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8649
diff
changeset
|
32 static ngx_int_t ngx_http_v3_parse_literal(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
33 ngx_http_v3_parse_literal_t *st, ngx_buf_t *b); |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
34 static ngx_int_t ngx_http_v3_parse_field_ri(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
35 ngx_http_v3_parse_field_t *st, ngx_buf_t *b); |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
36 static ngx_int_t ngx_http_v3_parse_field_lri(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
37 ngx_http_v3_parse_field_t *st, ngx_buf_t *b); |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
38 static ngx_int_t ngx_http_v3_parse_field_l(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
39 ngx_http_v3_parse_field_t *st, ngx_buf_t *b); |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
40 static ngx_int_t ngx_http_v3_parse_field_pbi(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
41 ngx_http_v3_parse_field_t *st, ngx_buf_t *b); |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
42 static ngx_int_t ngx_http_v3_parse_field_lpbi(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
43 ngx_http_v3_parse_field_t *st, ngx_buf_t *b); |
8666
ab6aaa8e86b0
HTTP/3: staticize internal parsing functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8649
diff
changeset
|
44 |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
45 static ngx_int_t ngx_http_v3_parse_control(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
46 ngx_http_v3_parse_control_t *st, ngx_buf_t *b); |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
47 static ngx_int_t ngx_http_v3_parse_settings(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
48 ngx_http_v3_parse_settings_t *st, ngx_buf_t *b); |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
49 |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
50 static ngx_int_t ngx_http_v3_parse_encoder(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
51 ngx_http_v3_parse_encoder_t *st, ngx_buf_t *b); |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
52 static ngx_int_t ngx_http_v3_parse_field_inr(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
53 ngx_http_v3_parse_field_t *st, ngx_buf_t *b); |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
54 static ngx_int_t ngx_http_v3_parse_field_iln(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
55 ngx_http_v3_parse_field_t *st, ngx_buf_t *b); |
8666
ab6aaa8e86b0
HTTP/3: staticize internal parsing functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8649
diff
changeset
|
56 |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
57 static ngx_int_t ngx_http_v3_parse_decoder(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
58 ngx_http_v3_parse_decoder_t *st, ngx_buf_t *b); |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
59 |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
60 static ngx_int_t ngx_http_v3_parse_lookup(ngx_connection_t *c, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
61 ngx_uint_t dynamic, ngx_uint_t index, ngx_str_t *name, ngx_str_t *value); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
62 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
63 |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
64 static void |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
65 ngx_http_v3_parse_start_local(ngx_buf_t *b, ngx_buf_t *loc, ngx_uint_t n) |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
66 { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
67 *loc = *b; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
68 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
69 if ((size_t) (loc->last - loc->pos) > n) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
70 loc->last = loc->pos + n; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
71 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
72 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
73 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
74 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
75 static void |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
76 ngx_http_v3_parse_end_local(ngx_buf_t *b, ngx_buf_t *loc, ngx_uint_t *pn) |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
77 { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
78 *pn -= loc->pos - b->pos; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
79 b->pos = loc->pos; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
80 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
81 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
82 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
83 static ngx_int_t |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
84 ngx_http_v3_parse_skip(ngx_buf_t *b, ngx_uint_t *length) |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
85 { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
86 if ((size_t) (b->last - b->pos) < *length) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
87 *length -= b->last - b->pos; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
88 b->pos = b->last; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
89 return NGX_AGAIN; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
90 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
91 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
92 b->pos += *length; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
93 return NGX_DONE; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
94 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
95 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
96 |
8666
ab6aaa8e86b0
HTTP/3: staticize internal parsing functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8649
diff
changeset
|
97 static ngx_int_t |
8226 | 98 ngx_http_v3_parse_varlen_int(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
99 ngx_http_v3_parse_varlen_int_t *st, ngx_buf_t *b) |
8226 | 100 { |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
101 u_char ch; |
8226 | 102 enum { |
103 sw_start = 0, | |
104 sw_length_2, | |
105 sw_length_3, | |
106 sw_length_4, | |
107 sw_length_5, | |
108 sw_length_6, | |
109 sw_length_7, | |
110 sw_length_8 | |
111 }; | |
112 | |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
113 for ( ;; ) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
114 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
115 if (b->pos == b->last) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
116 return NGX_AGAIN; |
8226 | 117 } |
118 | |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
119 ch = *b->pos++; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
120 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
121 switch (st->state) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
122 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
123 case sw_start: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
124 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
125 st->value = ch; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
126 if (st->value & 0xc0) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
127 st->state = sw_length_2; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
128 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
129 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
130 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
131 goto done; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
132 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
133 case sw_length_2: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
134 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
135 st->value = (st->value << 8) + ch; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
136 if ((st->value & 0xc000) == 0x4000) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
137 st->value &= 0x3fff; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
138 goto done; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
139 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
140 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
141 st->state = sw_length_3; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
142 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
143 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
144 case sw_length_4: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
145 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
146 st->value = (st->value << 8) + ch; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
147 if ((st->value & 0xc0000000) == 0x80000000) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
148 st->value &= 0x3fffffff; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
149 goto done; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
150 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
151 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
152 st->state = sw_length_5; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
153 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
154 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
155 case sw_length_3: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
156 case sw_length_5: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
157 case sw_length_6: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
158 case sw_length_7: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
159 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
160 st->value = (st->value << 8) + ch; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
161 st->state++; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
162 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
163 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
164 case sw_length_8: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
165 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
166 st->value = (st->value << 8) + ch; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
167 st->value &= 0x3fffffffffffffff; |
8226 | 168 goto done; |
169 } | |
170 } | |
171 | |
172 done: | |
173 | |
174 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
175 "http3 parse varlen int %uL", st->value); | |
176 | |
177 st->state = sw_start; | |
178 return NGX_DONE; | |
179 } | |
180 | |
181 | |
8666
ab6aaa8e86b0
HTTP/3: staticize internal parsing functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8649
diff
changeset
|
182 static ngx_int_t |
8226 | 183 ngx_http_v3_parse_prefix_int(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
184 ngx_http_v3_parse_prefix_int_t *st, ngx_uint_t prefix, ngx_buf_t *b) |
8226 | 185 { |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
186 u_char ch; |
8455
b0e81f49d7c0
HTTP/3: fixed prefixed integer encoding and decoding.
Roman Arutyunyan <arut@nginx.com>
parents:
8454
diff
changeset
|
187 ngx_uint_t mask; |
8226 | 188 enum { |
189 sw_start = 0, | |
190 sw_value | |
191 }; | |
192 | |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
193 for ( ;; ) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
194 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
195 if (b->pos == b->last) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
196 return NGX_AGAIN; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
197 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
198 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
199 ch = *b->pos++; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
200 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
201 switch (st->state) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
202 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
203 case sw_start: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
204 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
205 mask = (1 << prefix) - 1; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
206 st->value = ch & mask; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
207 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
208 if (st->value != mask) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
209 goto done; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
210 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
211 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
212 st->shift = 0; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
213 st->state = sw_value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
214 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
215 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
216 case sw_value: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
217 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
218 st->value += (uint64_t) (ch & 0x7f) << st->shift; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
219 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
220 if (st->shift == 56 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
221 && ((ch & 0x80) || (st->value & 0xc000000000000000))) |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
222 { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
223 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
224 "client exceeded integer size limit"); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
225 return NGX_HTTP_V3_ERR_EXCESSIVE_LOAD; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
226 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
227 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
228 if (ch & 0x80) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
229 st->shift += 7; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
230 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
231 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
232 |
8226 | 233 goto done; |
234 } | |
235 } | |
236 | |
237 done: | |
238 | |
239 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
240 "http3 parse prefix int %uL", st->value); | |
241 | |
242 st->state = sw_start; | |
243 return NGX_DONE; | |
244 } | |
245 | |
246 | |
247 ngx_int_t | |
248 ngx_http_v3_parse_headers(ngx_connection_t *c, ngx_http_v3_parse_headers_t *st, | |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
249 ngx_buf_t *b) |
8226 | 250 { |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
251 ngx_buf_t loc; |
8226 | 252 ngx_int_t rc; |
253 enum { | |
254 sw_start = 0, | |
8549
d70a38acaea0
HTTP/3: skip unknown frames on request stream.
Roman Arutyunyan <arut@nginx.com>
parents:
8497
diff
changeset
|
255 sw_type, |
8226 | 256 sw_length, |
8549
d70a38acaea0
HTTP/3: skip unknown frames on request stream.
Roman Arutyunyan <arut@nginx.com>
parents:
8497
diff
changeset
|
257 sw_skip, |
8226 | 258 sw_prefix, |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
259 sw_verify, |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
260 sw_field_rep, |
8226 | 261 sw_done |
262 }; | |
263 | |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
264 for ( ;; ) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
265 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
266 switch (st->state) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
267 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
268 case sw_start: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
269 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
270 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
271 "http3 parse headers"); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
272 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
273 st->state = sw_type; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
274 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
275 /* fall through */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
276 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
277 case sw_type: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
278 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
279 rc = ngx_http_v3_parse_varlen_int(c, &st->vlint, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
280 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
281 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
282 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
283 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
284 st->type = st->vlint.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
285 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
286 if (ngx_http_v3_is_v2_frame(st->type) |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
287 || st->type == NGX_HTTP_V3_FRAME_DATA |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
288 || st->type == NGX_HTTP_V3_FRAME_GOAWAY |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
289 || st->type == NGX_HTTP_V3_FRAME_SETTINGS |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
290 || st->type == NGX_HTTP_V3_FRAME_MAX_PUSH_ID |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
291 || st->type == NGX_HTTP_V3_FRAME_CANCEL_PUSH |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
292 || st->type == NGX_HTTP_V3_FRAME_PUSH_PROMISE) |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
293 { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
294 return NGX_HTTP_V3_ERR_FRAME_UNEXPECTED; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
295 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
296 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
297 st->state = sw_length; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
298 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
299 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
300 case sw_length: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
301 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
302 rc = ngx_http_v3_parse_varlen_int(c, &st->vlint, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
303 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
304 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
305 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
306 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
307 st->length = st->vlint.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
308 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
309 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
310 "http3 parse headers type:%ui, len:%ui", |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
311 st->type, st->length); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
312 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
313 if (st->type != NGX_HTTP_V3_FRAME_HEADERS) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
314 st->state = st->length > 0 ? sw_skip : sw_type; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
315 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
316 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
317 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
318 if (st->length == 0) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
319 return NGX_HTTP_V3_ERR_FRAME_ERROR; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
320 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
321 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
322 st->state = sw_prefix; |
8549
d70a38acaea0
HTTP/3: skip unknown frames on request stream.
Roman Arutyunyan <arut@nginx.com>
parents:
8497
diff
changeset
|
323 break; |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
324 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
325 case sw_skip: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
326 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
327 rc = ngx_http_v3_parse_skip(b, &st->length); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
328 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
329 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
330 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
331 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
332 st->state = sw_type; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
333 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
334 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
335 case sw_prefix: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
336 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
337 ngx_http_v3_parse_start_local(b, &loc, st->length); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
338 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
339 rc = ngx_http_v3_parse_field_section_prefix(c, &st->prefix, &loc); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
340 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
341 ngx_http_v3_parse_end_local(b, &loc, &st->length); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
342 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
343 if (st->length == 0 && rc == NGX_AGAIN) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
344 return NGX_HTTP_V3_ERR_FRAME_ERROR; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
345 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
346 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
347 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
348 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
349 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
350 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
351 st->state = sw_verify; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
352 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
353 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
354 case sw_verify: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
355 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
356 rc = ngx_http_v3_check_insert_count(c, st->prefix.insert_count); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
357 if (rc != NGX_OK) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
358 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
359 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
360 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
361 st->state = sw_field_rep; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
362 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
363 /* fall through */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
364 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
365 case sw_field_rep: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
366 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
367 ngx_http_v3_parse_start_local(b, &loc, st->length); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
368 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
369 rc = ngx_http_v3_parse_field_rep(c, &st->field_rep, st->prefix.base, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
370 &loc); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
371 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
372 ngx_http_v3_parse_end_local(b, &loc, &st->length); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
373 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
374 if (st->length == 0 && rc == NGX_AGAIN) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
375 return NGX_HTTP_V3_ERR_FRAME_ERROR; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
376 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
377 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
378 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
379 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
380 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
381 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
382 if (st->length == 0) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
383 goto done; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
384 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
385 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
386 return NGX_OK; |
8552
351d62300832
HTTP/3: rearranged length check when parsing header.
Roman Arutyunyan <arut@nginx.com>
parents:
8550
diff
changeset
|
387 } |
8226 | 388 } |
389 | |
390 done: | |
391 | |
392 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 parse headers done"); | |
393 | |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
394 if (st->prefix.insert_count > 0) { |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
395 if (ngx_http_v3_send_ack_section(c, c->quic->id) != NGX_OK) { |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
396 return NGX_ERROR; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
397 } |
8989
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8942
diff
changeset
|
398 |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8942
diff
changeset
|
399 ngx_http_v3_ack_insert_count(c, st->prefix.insert_count); |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
400 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
401 |
8226 | 402 st->state = sw_start; |
403 return NGX_DONE; | |
404 } | |
405 | |
406 | |
8666
ab6aaa8e86b0
HTTP/3: staticize internal parsing functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8649
diff
changeset
|
407 static ngx_int_t |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
408 ngx_http_v3_parse_field_section_prefix(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
409 ngx_http_v3_parse_field_section_prefix_t *st, ngx_buf_t *b) |
8226 | 410 { |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
411 u_char ch; |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
412 ngx_int_t rc; |
8226 | 413 enum { |
414 sw_start = 0, | |
415 sw_req_insert_count, | |
416 sw_delta_base, | |
417 sw_read_delta_base | |
418 }; | |
419 | |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
420 for ( ;; ) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
421 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
422 switch (st->state) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
423 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
424 case sw_start: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
425 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
426 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
427 "http3 parse field section prefix"); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
428 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
429 st->state = sw_req_insert_count; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
430 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
431 /* fall through */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
432 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
433 case sw_req_insert_count: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
434 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
435 rc = ngx_http_v3_parse_prefix_int(c, &st->pint, 8, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
436 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
437 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
438 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
439 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
440 st->insert_count = st->pint.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
441 st->state = sw_delta_base; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
442 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
443 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
444 case sw_delta_base: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
445 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
446 if (b->pos == b->last) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
447 return NGX_AGAIN; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
448 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
449 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
450 ch = *b->pos; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
451 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
452 st->sign = (ch & 0x80) ? 1 : 0; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
453 st->state = sw_read_delta_base; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
454 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
455 /* fall through */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
456 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
457 case sw_read_delta_base: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
458 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
459 rc = ngx_http_v3_parse_prefix_int(c, &st->pint, 7, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
460 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
461 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
462 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
463 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
464 st->delta_base = st->pint.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
465 goto done; |
8226 | 466 } |
467 } | |
468 | |
469 done: | |
470 | |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
471 rc = ngx_http_v3_decode_insert_count(c, &st->insert_count); |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
472 if (rc != NGX_OK) { |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
473 return rc; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
474 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
475 |
8226 | 476 if (st->sign) { |
9018
5b1011b5702b
HTTP/3: require that field section base index is not negative.
Roman Arutyunyan <arut@nginx.com>
parents:
8989
diff
changeset
|
477 if (st->insert_count <= st->delta_base) { |
5b1011b5702b
HTTP/3: require that field section base index is not negative.
Roman Arutyunyan <arut@nginx.com>
parents:
8989
diff
changeset
|
478 ngx_log_error(NGX_LOG_INFO, c->log, 0, "client sent negative base"); |
5b1011b5702b
HTTP/3: require that field section base index is not negative.
Roman Arutyunyan <arut@nginx.com>
parents:
8989
diff
changeset
|
479 return NGX_HTTP_V3_ERR_DECOMPRESSION_FAILED; |
5b1011b5702b
HTTP/3: require that field section base index is not negative.
Roman Arutyunyan <arut@nginx.com>
parents:
8989
diff
changeset
|
480 } |
5b1011b5702b
HTTP/3: require that field section base index is not negative.
Roman Arutyunyan <arut@nginx.com>
parents:
8989
diff
changeset
|
481 |
8226 | 482 st->base = st->insert_count - st->delta_base - 1; |
9018
5b1011b5702b
HTTP/3: require that field section base index is not negative.
Roman Arutyunyan <arut@nginx.com>
parents:
8989
diff
changeset
|
483 |
8226 | 484 } else { |
485 st->base = st->insert_count + st->delta_base; | |
486 } | |
487 | |
488 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
489 "http3 parse field section prefix done " |
8478
d2f716e668e8
Fixed format specifiers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8467
diff
changeset
|
490 "insert_count:%ui, sign:%ui, delta_base:%ui, base:%ui", |
8226 | 491 st->insert_count, st->sign, st->delta_base, st->base); |
492 | |
493 st->state = sw_start; | |
494 return NGX_DONE; | |
495 } | |
496 | |
497 | |
8666
ab6aaa8e86b0
HTTP/3: staticize internal parsing functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8649
diff
changeset
|
498 static ngx_int_t |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
499 ngx_http_v3_parse_field_rep(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
500 ngx_http_v3_parse_field_rep_t *st, ngx_uint_t base, ngx_buf_t *b) |
8226 | 501 { |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
502 u_char ch; |
8226 | 503 ngx_int_t rc; |
504 enum { | |
505 sw_start = 0, | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
506 sw_field_ri, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
507 sw_field_lri, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
508 sw_field_l, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
509 sw_field_pbi, |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
510 sw_field_lpbi |
8226 | 511 }; |
512 | |
513 if (st->state == sw_start) { | |
514 | |
515 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
516 "http3 parse field representation"); |
8226 | 517 |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
518 if (b->pos == b->last) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
519 return NGX_AGAIN; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
520 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
521 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
522 ch = *b->pos; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
523 |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
524 ngx_memzero(&st->field, sizeof(ngx_http_v3_parse_field_t)); |
8226 | 525 |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
526 st->field.base = base; |
8226 | 527 |
528 if (ch & 0x80) { | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
529 /* Indexed Field Line */ |
8226 | 530 |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
531 st->state = sw_field_ri; |
8226 | 532 |
533 } else if (ch & 0x40) { | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
534 /* Literal Field Line With Name Reference */ |
8226 | 535 |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
536 st->state = sw_field_lri; |
8226 | 537 |
538 } else if (ch & 0x20) { | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
539 /* Literal Field Line With Literal Name */ |
8226 | 540 |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
541 st->state = sw_field_l; |
8226 | 542 |
543 } else if (ch & 0x10) { | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
544 /* Indexed Field Line With Post-Base Index */ |
8226 | 545 |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
546 st->state = sw_field_pbi; |
8226 | 547 |
548 } else { | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
549 /* Literal Field Line With Post-Base Name Reference */ |
8226 | 550 |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
551 st->state = sw_field_lpbi; |
8226 | 552 } |
553 } | |
554 | |
555 switch (st->state) { | |
556 | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
557 case sw_field_ri: |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
558 rc = ngx_http_v3_parse_field_ri(c, &st->field, b); |
8226 | 559 break; |
560 | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
561 case sw_field_lri: |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
562 rc = ngx_http_v3_parse_field_lri(c, &st->field, b); |
8226 | 563 break; |
564 | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
565 case sw_field_l: |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
566 rc = ngx_http_v3_parse_field_l(c, &st->field, b); |
8226 | 567 break; |
568 | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
569 case sw_field_pbi: |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
570 rc = ngx_http_v3_parse_field_pbi(c, &st->field, b); |
8226 | 571 break; |
572 | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
573 case sw_field_lpbi: |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
574 rc = ngx_http_v3_parse_field_lpbi(c, &st->field, b); |
8226 | 575 break; |
576 | |
577 default: | |
578 rc = NGX_OK; | |
579 } | |
580 | |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
581 if (rc != NGX_DONE) { |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
582 return rc; |
8226 | 583 } |
584 | |
585 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
586 "http3 parse field representation done"); |
8226 | 587 |
588 st->state = sw_start; | |
589 return NGX_DONE; | |
590 } | |
591 | |
592 | |
8666
ab6aaa8e86b0
HTTP/3: staticize internal parsing functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8649
diff
changeset
|
593 static ngx_int_t |
8226 | 594 ngx_http_v3_parse_literal(ngx_connection_t *c, ngx_http_v3_parse_literal_t *st, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
595 ngx_buf_t *b) |
8226 | 596 { |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
597 u_char ch; |
8705
ae2e68f206f9
HTTP/3: removed http3_max_field_size.
Roman Arutyunyan <arut@nginx.com>
parents:
8666
diff
changeset
|
598 ngx_uint_t n; |
ae2e68f206f9
HTTP/3: removed http3_max_field_size.
Roman Arutyunyan <arut@nginx.com>
parents:
8666
diff
changeset
|
599 ngx_http_core_srv_conf_t *cscf; |
8226 | 600 enum { |
601 sw_start = 0, | |
602 sw_value | |
603 }; | |
604 | |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
605 for ( ;; ) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
606 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
607 switch (st->state) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
608 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
609 case sw_start: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
610 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
611 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
612 "http3 parse literal huff:%ui, len:%ui", |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
613 st->huffman, st->length); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
614 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
615 n = st->length; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
616 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
617 cscf = ngx_http_v3_get_module_srv_conf(c, ngx_http_core_module); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
618 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
619 if (n > cscf->large_client_header_buffers.size) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
620 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
621 "client sent too large field line"); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
622 return NGX_HTTP_V3_ERR_EXCESSIVE_LOAD; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
623 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
624 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
625 if (st->huffman) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
626 n = n * 8 / 5; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
627 st->huffstate = 0; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
628 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
629 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
630 st->last = ngx_pnalloc(c->pool, n + 1); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
631 if (st->last == NULL) { |
8226 | 632 return NGX_ERROR; |
633 } | |
634 | |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
635 st->value.data = st->last; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
636 st->state = sw_value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
637 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
638 /* fall through */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
639 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
640 case sw_value: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
641 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
642 if (b->pos == b->last) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
643 return NGX_AGAIN; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
644 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
645 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
646 ch = *b->pos++; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
647 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
648 if (st->huffman) { |
8942
5c86189a1c1b
Merged with the default branch.
Ruslan Ermilov <ru@nginx.com>
parents:
8838
diff
changeset
|
649 if (ngx_http_huff_decode(&st->huffstate, &ch, 1, &st->last, |
5c86189a1c1b
Merged with the default branch.
Ruslan Ermilov <ru@nginx.com>
parents:
8838
diff
changeset
|
650 st->length == 1, c->log) |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
651 != NGX_OK) |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
652 { |
9186
f366007dd23a
HTTP/3: added Huffman decoding error logging.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9108
diff
changeset
|
653 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
f366007dd23a
HTTP/3: added Huffman decoding error logging.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9108
diff
changeset
|
654 "client sent invalid encoded field line"); |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
655 return NGX_ERROR; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
656 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
657 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
658 } else { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
659 *st->last++ = ch; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
660 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
661 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
662 if (--st->length) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
663 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
664 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
665 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
666 st->value.len = st->last - st->value.data; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
667 *st->last = '\0'; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
668 goto done; |
8226 | 669 } |
670 } | |
671 | |
672 done: | |
673 | |
674 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
675 "http3 parse literal done \"%V\"", &st->value); | |
676 | |
677 st->state = sw_start; | |
678 return NGX_DONE; | |
679 } | |
680 | |
681 | |
8666
ab6aaa8e86b0
HTTP/3: staticize internal parsing functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8649
diff
changeset
|
682 static ngx_int_t |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
683 ngx_http_v3_parse_field_ri(ngx_connection_t *c, ngx_http_v3_parse_field_t *st, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
684 ngx_buf_t *b) |
8226 | 685 { |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
686 u_char ch; |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
687 ngx_int_t rc; |
8226 | 688 enum { |
689 sw_start = 0, | |
690 sw_index | |
691 }; | |
692 | |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
693 for ( ;; ) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
694 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
695 switch (st->state) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
696 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
697 case sw_start: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
698 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
699 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
700 "http3 parse field ri"); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
701 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
702 if (b->pos == b->last) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
703 return NGX_AGAIN; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
704 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
705 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
706 ch = *b->pos; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
707 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
708 st->dynamic = (ch & 0x40) ? 0 : 1; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
709 st->state = sw_index; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
710 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
711 /* fall through */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
712 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
713 case sw_index: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
714 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
715 rc = ngx_http_v3_parse_prefix_int(c, &st->pint, 6, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
716 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
717 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
718 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
719 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
720 st->index = st->pint.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
721 goto done; |
8226 | 722 } |
723 } | |
724 | |
725 done: | |
726 | |
727 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
728 "http3 parse field ri done %s%ui]", |
8226 | 729 st->dynamic ? "dynamic[-" : "static[", st->index); |
730 | |
731 if (st->dynamic) { | |
732 st->index = st->base - st->index - 1; | |
733 } | |
734 | |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
735 rc = ngx_http_v3_parse_lookup(c, st->dynamic, st->index, &st->name, |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
736 &st->value); |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
737 if (rc != NGX_OK) { |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
738 return rc; |
8226 | 739 } |
740 | |
741 st->state = sw_start; | |
742 return NGX_DONE; | |
743 } | |
744 | |
745 | |
8666
ab6aaa8e86b0
HTTP/3: staticize internal parsing functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8649
diff
changeset
|
746 static ngx_int_t |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
747 ngx_http_v3_parse_field_lri(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
748 ngx_http_v3_parse_field_t *st, ngx_buf_t *b) |
8226 | 749 { |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
750 u_char ch; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
751 ngx_int_t rc; |
8226 | 752 enum { |
753 sw_start = 0, | |
754 sw_index, | |
755 sw_value_len, | |
756 sw_read_value_len, | |
757 sw_value | |
758 }; | |
759 | |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
760 for ( ;; ) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
761 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
762 switch (st->state) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
763 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
764 case sw_start: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
765 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
766 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
767 "http3 parse field lri"); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
768 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
769 if (b->pos == b->last) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
770 return NGX_AGAIN; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
771 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
772 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
773 ch = *b->pos; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
774 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
775 st->dynamic = (ch & 0x10) ? 0 : 1; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
776 st->state = sw_index; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
777 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
778 /* fall through */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
779 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
780 case sw_index: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
781 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
782 rc = ngx_http_v3_parse_prefix_int(c, &st->pint, 4, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
783 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
784 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
785 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
786 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
787 st->index = st->pint.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
788 st->state = sw_value_len; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
789 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
790 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
791 case sw_value_len: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
792 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
793 if (b->pos == b->last) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
794 return NGX_AGAIN; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
795 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
796 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
797 ch = *b->pos; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
798 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
799 st->literal.huffman = (ch & 0x80) ? 1 : 0; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
800 st->state = sw_read_value_len; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
801 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
802 /* fall through */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
803 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
804 case sw_read_value_len: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
805 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
806 rc = ngx_http_v3_parse_prefix_int(c, &st->pint, 7, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
807 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
808 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
809 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
810 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
811 st->literal.length = st->pint.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
812 if (st->literal.length == 0) { |
9285
4c7a9355bcae
HTTP/3: fixed handling of zero-length literal field line.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9186
diff
changeset
|
813 st->value.data = (u_char *) ""; |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
814 goto done; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
815 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
816 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
817 st->state = sw_value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
818 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
819 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
820 case sw_value: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
821 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
822 rc = ngx_http_v3_parse_literal(c, &st->literal, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
823 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
824 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
825 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
826 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
827 st->value = st->literal.value; |
8226 | 828 goto done; |
829 } | |
830 } | |
831 | |
832 done: | |
833 | |
834 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
835 "http3 parse field lri done %s%ui] \"%V\"", |
8226 | 836 st->dynamic ? "dynamic[-" : "static[", |
837 st->index, &st->value); | |
838 | |
839 if (st->dynamic) { | |
840 st->index = st->base - st->index - 1; | |
841 } | |
842 | |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
843 rc = ngx_http_v3_parse_lookup(c, st->dynamic, st->index, &st->name, NULL); |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
844 if (rc != NGX_OK) { |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
845 return rc; |
8226 | 846 } |
847 | |
848 st->state = sw_start; | |
849 return NGX_DONE; | |
850 } | |
851 | |
852 | |
8666
ab6aaa8e86b0
HTTP/3: staticize internal parsing functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8649
diff
changeset
|
853 static ngx_int_t |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
854 ngx_http_v3_parse_field_l(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
855 ngx_http_v3_parse_field_t *st, ngx_buf_t *b) |
8226 | 856 { |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
857 u_char ch; |
8226 | 858 ngx_int_t rc; |
859 enum { | |
860 sw_start = 0, | |
861 sw_name_len, | |
862 sw_name, | |
863 sw_value_len, | |
864 sw_read_value_len, | |
865 sw_value | |
866 }; | |
867 | |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
868 for ( ;; ) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
869 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
870 switch (st->state) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
871 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
872 case sw_start: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
873 |
9105 | 874 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
875 "http3 parse field l"); | |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
876 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
877 if (b->pos == b->last) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
878 return NGX_AGAIN; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
879 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
880 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
881 ch = *b->pos; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
882 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
883 st->literal.huffman = (ch & 0x08) ? 1 : 0; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
884 st->state = sw_name_len; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
885 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
886 /* fall through */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
887 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
888 case sw_name_len: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
889 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
890 rc = ngx_http_v3_parse_prefix_int(c, &st->pint, 3, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
891 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
892 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
893 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
894 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
895 st->literal.length = st->pint.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
896 if (st->literal.length == 0) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
897 return NGX_ERROR; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
898 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
899 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
900 st->state = sw_name; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
901 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
902 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
903 case sw_name: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
904 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
905 rc = ngx_http_v3_parse_literal(c, &st->literal, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
906 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
907 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
908 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
909 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
910 st->name = st->literal.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
911 st->state = sw_value_len; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
912 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
913 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
914 case sw_value_len: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
915 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
916 if (b->pos == b->last) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
917 return NGX_AGAIN; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
918 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
919 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
920 ch = *b->pos; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
921 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
922 st->literal.huffman = (ch & 0x80) ? 1 : 0; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
923 st->state = sw_read_value_len; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
924 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
925 /* fall through */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
926 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
927 case sw_read_value_len: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
928 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
929 rc = ngx_http_v3_parse_prefix_int(c, &st->pint, 7, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
930 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
931 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
932 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
933 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
934 st->literal.length = st->pint.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
935 if (st->literal.length == 0) { |
9285
4c7a9355bcae
HTTP/3: fixed handling of zero-length literal field line.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9186
diff
changeset
|
936 st->value.data = (u_char *) ""; |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
937 goto done; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
938 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
939 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
940 st->state = sw_value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
941 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
942 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
943 case sw_value: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
944 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
945 rc = ngx_http_v3_parse_literal(c, &st->literal, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
946 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
947 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
948 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
949 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
950 st->value = st->literal.value; |
8226 | 951 goto done; |
952 } | |
953 } | |
954 | |
955 done: | |
956 | |
957 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
958 "http3 parse field l done \"%V\" \"%V\"", |
8226 | 959 &st->name, &st->value); |
960 | |
961 st->state = sw_start; | |
962 return NGX_DONE; | |
963 } | |
964 | |
965 | |
8666
ab6aaa8e86b0
HTTP/3: staticize internal parsing functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8649
diff
changeset
|
966 static ngx_int_t |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
967 ngx_http_v3_parse_field_pbi(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
968 ngx_http_v3_parse_field_t *st, ngx_buf_t *b) |
8226 | 969 { |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
970 ngx_int_t rc; |
8226 | 971 enum { |
972 sw_start = 0, | |
973 sw_index | |
974 }; | |
975 | |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
976 for ( ;; ) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
977 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
978 switch (st->state) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
979 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
980 case sw_start: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
981 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
982 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
983 "http3 parse field pbi"); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
984 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
985 st->state = sw_index; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
986 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
987 /* fall through */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
988 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
989 case sw_index: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
990 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
991 rc = ngx_http_v3_parse_prefix_int(c, &st->pint, 4, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
992 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
993 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
994 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
995 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
996 st->index = st->pint.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
997 goto done; |
8226 | 998 } |
999 } | |
1000 | |
1001 done: | |
1002 | |
1003 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
1004 "http3 parse field pbi done dynamic[+%ui]", st->index); |
8226 | 1005 |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
1006 rc = ngx_http_v3_parse_lookup(c, 1, st->base + st->index, &st->name, |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
1007 &st->value); |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
1008 if (rc != NGX_OK) { |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
1009 return rc; |
8226 | 1010 } |
1011 | |
1012 st->state = sw_start; | |
1013 return NGX_DONE; | |
1014 } | |
1015 | |
1016 | |
8666
ab6aaa8e86b0
HTTP/3: staticize internal parsing functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8649
diff
changeset
|
1017 static ngx_int_t |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
1018 ngx_http_v3_parse_field_lpbi(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1019 ngx_http_v3_parse_field_t *st, ngx_buf_t *b) |
8226 | 1020 { |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1021 u_char ch; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1022 ngx_int_t rc; |
8226 | 1023 enum { |
1024 sw_start = 0, | |
1025 sw_index, | |
1026 sw_value_len, | |
1027 sw_read_value_len, | |
1028 sw_value | |
1029 }; | |
1030 | |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1031 for ( ;; ) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1032 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1033 switch (st->state) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1034 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1035 case sw_start: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1036 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1037 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1038 "http3 parse field lpbi"); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1039 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1040 st->state = sw_index; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1041 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1042 /* fall through */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1043 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1044 case sw_index: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1045 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1046 rc = ngx_http_v3_parse_prefix_int(c, &st->pint, 3, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1047 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1048 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1049 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1050 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1051 st->index = st->pint.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1052 st->state = sw_value_len; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1053 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1054 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1055 case sw_value_len: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1056 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1057 if (b->pos == b->last) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1058 return NGX_AGAIN; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1059 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1060 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1061 ch = *b->pos; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1062 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1063 st->literal.huffman = (ch & 0x80) ? 1 : 0; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1064 st->state = sw_read_value_len; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1065 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1066 /* fall through */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1067 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1068 case sw_read_value_len: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1069 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1070 rc = ngx_http_v3_parse_prefix_int(c, &st->pint, 7, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1071 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1072 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1073 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1074 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1075 st->literal.length = st->pint.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1076 if (st->literal.length == 0) { |
9285
4c7a9355bcae
HTTP/3: fixed handling of zero-length literal field line.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9186
diff
changeset
|
1077 st->value.data = (u_char *) ""; |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1078 goto done; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1079 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1080 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1081 st->state = sw_value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1082 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1083 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1084 case sw_value: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1085 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1086 rc = ngx_http_v3_parse_literal(c, &st->literal, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1087 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1088 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1089 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1090 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1091 st->value = st->literal.value; |
8226 | 1092 goto done; |
1093 } | |
1094 } | |
1095 | |
1096 done: | |
1097 | |
1098 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
1099 "http3 parse field lpbi done dynamic[+%ui] \"%V\"", |
8226 | 1100 st->index, &st->value); |
1101 | |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
1102 rc = ngx_http_v3_parse_lookup(c, 1, st->base + st->index, &st->name, NULL); |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
1103 if (rc != NGX_OK) { |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
1104 return rc; |
8226 | 1105 } |
1106 | |
1107 st->state = sw_start; | |
1108 return NGX_DONE; | |
1109 } | |
1110 | |
1111 | |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1112 static ngx_int_t |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1113 ngx_http_v3_parse_lookup(ngx_connection_t *c, ngx_uint_t dynamic, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1114 ngx_uint_t index, ngx_str_t *name, ngx_str_t *value) |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1115 { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1116 u_char *p; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1117 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1118 if (!dynamic) { |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
1119 if (ngx_http_v3_lookup_static(c, index, name, value) != NGX_OK) { |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
1120 return NGX_HTTP_V3_ERR_DECOMPRESSION_FAILED; |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
1121 } |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
1122 |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
1123 return NGX_OK; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1124 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1125 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1126 if (ngx_http_v3_lookup(c, index, name, value) != NGX_OK) { |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
1127 return NGX_HTTP_V3_ERR_DECOMPRESSION_FAILED; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1128 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1129 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1130 if (name) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1131 p = ngx_pnalloc(c->pool, name->len + 1); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1132 if (p == NULL) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1133 return NGX_ERROR; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1134 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1135 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1136 ngx_memcpy(p, name->data, name->len); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1137 p[name->len] = '\0'; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1138 name->data = p; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1139 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1140 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1141 if (value) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1142 p = ngx_pnalloc(c->pool, value->len + 1); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1143 if (p == NULL) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1144 return NGX_ERROR; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1145 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1146 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1147 ngx_memcpy(p, value->data, value->len); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1148 p[value->len] = '\0'; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1149 value->data = p; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1150 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1151 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1152 return NGX_OK; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1153 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1154 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8455
diff
changeset
|
1155 |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1156 static ngx_int_t |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1157 ngx_http_v3_parse_control(ngx_connection_t *c, ngx_http_v3_parse_control_t *st, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1158 ngx_buf_t *b) |
8226 | 1159 { |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1160 ngx_buf_t loc; |
8226 | 1161 ngx_int_t rc; |
1162 enum { | |
1163 sw_start = 0, | |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
1164 sw_first_type, |
8226 | 1165 sw_type, |
1166 sw_length, | |
1167 sw_settings, | |
1168 sw_skip | |
1169 }; | |
1170 | |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1171 for ( ;; ) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1172 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1173 switch (st->state) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1174 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1175 case sw_start: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1176 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1177 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1178 "http3 parse control"); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1179 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1180 st->state = sw_first_type; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1181 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1182 /* fall through */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1183 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1184 case sw_first_type: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1185 case sw_type: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1186 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1187 rc = ngx_http_v3_parse_varlen_int(c, &st->vlint, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1188 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1189 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1190 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1191 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1192 st->type = st->vlint.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1193 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1194 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1195 "http3 parse frame type:%ui", st->type); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1196 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1197 if (st->state == sw_first_type |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1198 && st->type != NGX_HTTP_V3_FRAME_SETTINGS) |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1199 { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1200 return NGX_HTTP_V3_ERR_MISSING_SETTINGS; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1201 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1202 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1203 if (st->state != sw_first_type |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1204 && st->type == NGX_HTTP_V3_FRAME_SETTINGS) |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1205 { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1206 return NGX_HTTP_V3_ERR_FRAME_UNEXPECTED; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1207 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1208 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1209 if (ngx_http_v3_is_v2_frame(st->type) |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1210 || st->type == NGX_HTTP_V3_FRAME_DATA |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1211 || st->type == NGX_HTTP_V3_FRAME_HEADERS |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1212 || st->type == NGX_HTTP_V3_FRAME_PUSH_PROMISE) |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1213 { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1214 return NGX_HTTP_V3_ERR_FRAME_UNEXPECTED; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1215 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1216 |
9108
f742b1b46901
HTTP/3: removed server push support.
Roman Arutyunyan <arut@nginx.com>
parents:
9105
diff
changeset
|
1217 if (st->type == NGX_HTTP_V3_FRAME_CANCEL_PUSH) { |
f742b1b46901
HTTP/3: removed server push support.
Roman Arutyunyan <arut@nginx.com>
parents:
9105
diff
changeset
|
1218 return NGX_HTTP_V3_ERR_ID_ERROR; |
f742b1b46901
HTTP/3: removed server push support.
Roman Arutyunyan <arut@nginx.com>
parents:
9105
diff
changeset
|
1219 } |
f742b1b46901
HTTP/3: removed server push support.
Roman Arutyunyan <arut@nginx.com>
parents:
9105
diff
changeset
|
1220 |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1221 st->state = sw_length; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1222 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1223 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1224 case sw_length: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1225 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1226 rc = ngx_http_v3_parse_varlen_int(c, &st->vlint, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1227 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1228 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1229 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1230 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1231 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1232 "http3 parse frame len:%uL", st->vlint.value); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1233 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1234 st->length = st->vlint.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1235 if (st->length == 0) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1236 st->state = sw_type; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1237 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1238 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1239 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1240 switch (st->type) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1241 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1242 case NGX_HTTP_V3_FRAME_SETTINGS: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1243 st->state = sw_settings; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1244 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1245 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1246 default: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1247 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1248 "http3 parse skip unknown frame"); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1249 st->state = sw_skip; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1250 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1251 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1252 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1253 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1254 case sw_settings: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1255 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1256 ngx_http_v3_parse_start_local(b, &loc, st->length); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1257 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1258 rc = ngx_http_v3_parse_settings(c, &st->settings, &loc); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1259 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1260 ngx_http_v3_parse_end_local(b, &loc, &st->length); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1261 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1262 if (st->length == 0 && rc == NGX_AGAIN) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1263 return NGX_HTTP_V3_ERR_SETTINGS_ERROR; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1264 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1265 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1266 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1267 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1268 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1269 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1270 if (st->length == 0) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1271 st->state = sw_type; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1272 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1273 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1274 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1275 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1276 case sw_skip: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1277 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1278 rc = ngx_http_v3_parse_skip(b, &st->length); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1279 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1280 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1281 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1282 |
8226 | 1283 st->state = sw_type; |
1284 break; | |
1285 } | |
1286 } | |
1287 } | |
1288 | |
1289 | |
8666
ab6aaa8e86b0
HTTP/3: staticize internal parsing functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8649
diff
changeset
|
1290 static ngx_int_t |
8226 | 1291 ngx_http_v3_parse_settings(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1292 ngx_http_v3_parse_settings_t *st, ngx_buf_t *b) |
8226 | 1293 { |
8466
4fd709540daf
HTTP/3: put ngx_http_v3_parse_varlen_int() return code in variable.
Roman Arutyunyan <arut@nginx.com>
parents:
8465
diff
changeset
|
1294 ngx_int_t rc; |
8226 | 1295 enum { |
1296 sw_start = 0, | |
1297 sw_id, | |
1298 sw_value | |
1299 }; | |
1300 | |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1301 for ( ;; ) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1302 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1303 switch (st->state) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1304 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1305 case sw_start: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1306 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1307 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1308 "http3 parse settings"); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1309 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1310 st->state = sw_id; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1311 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1312 /* fall through */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1313 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1314 case sw_id: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1315 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1316 rc = ngx_http_v3_parse_varlen_int(c, &st->vlint, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1317 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1318 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1319 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1320 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1321 st->id = st->vlint.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1322 st->state = sw_value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1323 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1324 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1325 case sw_value: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1326 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1327 rc = ngx_http_v3_parse_varlen_int(c, &st->vlint, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1328 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1329 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1330 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1331 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1332 if (ngx_http_v3_set_param(c, st->id, st->vlint.value) != NGX_OK) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1333 return NGX_HTTP_V3_ERR_SETTINGS_ERROR; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1334 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1335 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1336 goto done; |
8226 | 1337 } |
1338 } | |
1339 | |
1340 done: | |
1341 | |
1342 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 parse settings done"); | |
1343 | |
1344 st->state = sw_start; | |
1345 return NGX_DONE; | |
1346 } | |
1347 | |
1348 | |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1349 static ngx_int_t |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1350 ngx_http_v3_parse_encoder(ngx_connection_t *c, ngx_http_v3_parse_encoder_t *st, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1351 ngx_buf_t *b) |
8226 | 1352 { |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1353 u_char ch; |
8226 | 1354 ngx_int_t rc; |
1355 enum { | |
1356 sw_start = 0, | |
1357 sw_inr, | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
1358 sw_iln, |
8226 | 1359 sw_capacity, |
1360 sw_duplicate | |
1361 }; | |
1362 | |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1363 for ( ;; ) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1364 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1365 if (st->state == sw_start) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1366 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1367 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1368 "http3 parse encoder instruction"); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1369 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1370 if (b->pos == b->last) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1371 return NGX_AGAIN; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1372 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1373 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1374 ch = *b->pos; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1375 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1376 if (ch & 0x80) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1377 /* Insert With Name Reference */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1378 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1379 st->state = sw_inr; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1380 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1381 } else if (ch & 0x40) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1382 /* Insert With Literal Name */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1383 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1384 st->state = sw_iln; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1385 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1386 } else if (ch & 0x20) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1387 /* Set Dynamic Table Capacity */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1388 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1389 st->state = sw_capacity; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1390 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1391 } else { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1392 /* Duplicate */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1393 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1394 st->state = sw_duplicate; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1395 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1396 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1397 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1398 switch (st->state) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1399 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1400 case sw_inr: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1401 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1402 rc = ngx_http_v3_parse_field_inr(c, &st->field, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1403 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1404 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1405 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1406 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1407 st->state = sw_start; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1408 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1409 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1410 case sw_iln: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1411 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1412 rc = ngx_http_v3_parse_field_iln(c, &st->field, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1413 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1414 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1415 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1416 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1417 st->state = sw_start; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1418 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1419 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1420 case sw_capacity: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1421 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1422 rc = ngx_http_v3_parse_prefix_int(c, &st->pint, 5, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1423 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1424 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1425 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1426 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1427 rc = ngx_http_v3_set_capacity(c, st->pint.value); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1428 if (rc != NGX_OK) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1429 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1430 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1431 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1432 st->state = sw_start; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1433 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1434 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1435 default: /* sw_duplicate */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1436 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1437 rc = ngx_http_v3_parse_prefix_int(c, &st->pint, 5, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1438 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1439 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1440 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1441 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1442 rc = ngx_http_v3_duplicate(c, st->pint.value); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1443 if (rc != NGX_OK) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1444 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1445 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1446 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1447 st->state = sw_start; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1448 break; |
8226 | 1449 } |
1450 } | |
1451 } | |
1452 | |
1453 | |
8666
ab6aaa8e86b0
HTTP/3: staticize internal parsing functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8649
diff
changeset
|
1454 static ngx_int_t |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
1455 ngx_http_v3_parse_field_inr(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1456 ngx_http_v3_parse_field_t *st, ngx_buf_t *b) |
8226 | 1457 { |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1458 u_char ch; |
8226 | 1459 ngx_int_t rc; |
1460 enum { | |
1461 sw_start = 0, | |
1462 sw_name_index, | |
1463 sw_value_len, | |
1464 sw_read_value_len, | |
1465 sw_value | |
1466 }; | |
1467 | |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1468 for ( ;; ) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1469 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1470 switch (st->state) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1471 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1472 case sw_start: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1473 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1474 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1475 "http3 parse field inr"); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1476 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1477 if (b->pos == b->last) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1478 return NGX_AGAIN; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1479 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1480 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1481 ch = *b->pos; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1482 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1483 st->dynamic = (ch & 0x40) ? 0 : 1; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1484 st->state = sw_name_index; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1485 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1486 /* fall through */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1487 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1488 case sw_name_index: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1489 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1490 rc = ngx_http_v3_parse_prefix_int(c, &st->pint, 6, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1491 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1492 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1493 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1494 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1495 st->index = st->pint.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1496 st->state = sw_value_len; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1497 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1498 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1499 case sw_value_len: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1500 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1501 if (b->pos == b->last) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1502 return NGX_AGAIN; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1503 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1504 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1505 ch = *b->pos; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1506 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1507 st->literal.huffman = (ch & 0x80) ? 1 : 0; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1508 st->state = sw_read_value_len; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1509 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1510 /* fall through */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1511 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1512 case sw_read_value_len: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1513 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1514 rc = ngx_http_v3_parse_prefix_int(c, &st->pint, 7, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1515 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1516 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1517 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1518 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1519 st->literal.length = st->pint.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1520 if (st->literal.length == 0) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1521 st->value.len = 0; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1522 goto done; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1523 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1524 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1525 st->state = sw_value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1526 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1527 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1528 case sw_value: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1529 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1530 rc = ngx_http_v3_parse_literal(c, &st->literal, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1531 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1532 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1533 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1534 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1535 st->value = st->literal.value; |
8226 | 1536 goto done; |
1537 } | |
1538 } | |
1539 | |
1540 done: | |
1541 | |
1542 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
1543 "http3 parse field inr done %s[%ui] \"%V\"", |
8226 | 1544 st->dynamic ? "dynamic" : "static", |
1545 st->index, &st->value); | |
1546 | |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
1547 rc = ngx_http_v3_ref_insert(c, st->dynamic, st->index, &st->value); |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
1548 if (rc != NGX_OK) { |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
1549 return rc; |
8226 | 1550 } |
1551 | |
1552 st->state = sw_start; | |
1553 return NGX_DONE; | |
1554 } | |
1555 | |
1556 | |
8666
ab6aaa8e86b0
HTTP/3: staticize internal parsing functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8649
diff
changeset
|
1557 static ngx_int_t |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
1558 ngx_http_v3_parse_field_iln(ngx_connection_t *c, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1559 ngx_http_v3_parse_field_t *st, ngx_buf_t *b) |
8226 | 1560 { |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1561 u_char ch; |
8226 | 1562 ngx_int_t rc; |
1563 enum { | |
1564 sw_start = 0, | |
1565 sw_name_len, | |
1566 sw_name, | |
1567 sw_value_len, | |
1568 sw_read_value_len, | |
1569 sw_value | |
1570 }; | |
1571 | |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1572 for ( ;; ) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1573 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1574 switch (st->state) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1575 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1576 case sw_start: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1577 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1578 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1579 "http3 parse field iln"); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1580 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1581 if (b->pos == b->last) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1582 return NGX_AGAIN; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1583 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1584 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1585 ch = *b->pos; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1586 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1587 st->literal.huffman = (ch & 0x20) ? 1 : 0; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1588 st->state = sw_name_len; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1589 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1590 /* fall through */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1591 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1592 case sw_name_len: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1593 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1594 rc = ngx_http_v3_parse_prefix_int(c, &st->pint, 5, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1595 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1596 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1597 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1598 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1599 st->literal.length = st->pint.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1600 if (st->literal.length == 0) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1601 return NGX_ERROR; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1602 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1603 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1604 st->state = sw_name; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1605 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1606 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1607 case sw_name: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1608 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1609 rc = ngx_http_v3_parse_literal(c, &st->literal, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1610 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1611 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1612 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1613 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1614 st->name = st->literal.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1615 st->state = sw_value_len; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1616 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1617 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1618 case sw_value_len: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1619 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1620 if (b->pos == b->last) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1621 return NGX_AGAIN; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1622 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1623 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1624 ch = *b->pos; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1625 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1626 st->literal.huffman = (ch & 0x80) ? 1 : 0; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1627 st->state = sw_read_value_len; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1628 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1629 /* fall through */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1630 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1631 case sw_read_value_len: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1632 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1633 rc = ngx_http_v3_parse_prefix_int(c, &st->pint, 7, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1634 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1635 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1636 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1637 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1638 st->literal.length = st->pint.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1639 if (st->literal.length == 0) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1640 st->value.len = 0; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1641 goto done; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1642 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1643 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1644 st->state = sw_value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1645 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1646 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1647 case sw_value: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1648 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1649 rc = ngx_http_v3_parse_literal(c, &st->literal, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1650 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1651 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1652 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1653 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1654 st->value = st->literal.value; |
8226 | 1655 goto done; |
1656 } | |
1657 } | |
1658 | |
1659 done: | |
1660 | |
1661 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
1662 "http3 parse field iln done \"%V\":\"%V\"", |
8226 | 1663 &st->name, &st->value); |
1664 | |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
1665 rc = ngx_http_v3_insert(c, &st->name, &st->value); |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
1666 if (rc != NGX_OK) { |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
1667 return rc; |
8226 | 1668 } |
1669 | |
1670 st->state = sw_start; | |
1671 return NGX_DONE; | |
1672 } | |
1673 | |
1674 | |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1675 static ngx_int_t |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1676 ngx_http_v3_parse_decoder(ngx_connection_t *c, ngx_http_v3_parse_decoder_t *st, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1677 ngx_buf_t *b) |
8226 | 1678 { |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1679 u_char ch; |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8457
diff
changeset
|
1680 ngx_int_t rc; |
8226 | 1681 enum { |
1682 sw_start = 0, | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
1683 sw_ack_section, |
8226 | 1684 sw_cancel_stream, |
1685 sw_inc_insert_count | |
1686 }; | |
1687 | |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1688 for ( ;; ) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1689 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1690 if (st->state == sw_start) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1691 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1692 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1693 "http3 parse decoder instruction"); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1694 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1695 if (b->pos == b->last) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1696 return NGX_AGAIN; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1697 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1698 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1699 ch = *b->pos; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1700 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1701 if (ch & 0x80) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1702 /* Section Acknowledgment */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1703 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1704 st->state = sw_ack_section; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1705 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1706 } else if (ch & 0x40) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1707 /* Stream Cancellation */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1708 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1709 st->state = sw_cancel_stream; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1710 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1711 } else { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1712 /* Insert Count Increment */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1713 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1714 st->state = sw_inc_insert_count; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1715 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1716 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1717 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1718 switch (st->state) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1719 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1720 case sw_ack_section: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1721 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1722 rc = ngx_http_v3_parse_prefix_int(c, &st->pint, 7, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1723 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1724 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1725 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1726 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1727 rc = ngx_http_v3_ack_section(c, st->pint.value); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1728 if (rc != NGX_OK) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1729 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1730 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1731 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1732 st->state = sw_start; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1733 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1734 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1735 case sw_cancel_stream: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1736 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1737 rc = ngx_http_v3_parse_prefix_int(c, &st->pint, 6, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1738 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1739 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1740 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1741 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1742 rc = ngx_http_v3_cancel_stream(c, st->pint.value); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1743 if (rc != NGX_OK) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1744 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1745 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1746 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1747 st->state = sw_start; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1748 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1749 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1750 case sw_inc_insert_count: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1751 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1752 rc = ngx_http_v3_parse_prefix_int(c, &st->pint, 6, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1753 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1754 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1755 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1756 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1757 rc = ngx_http_v3_inc_insert_count(c, st->pint.value); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1758 if (rc != NGX_OK) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1759 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1760 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1761 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1762 st->state = sw_start; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1763 break; |
8226 | 1764 } |
1765 } | |
1766 } | |
8295
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
8227
diff
changeset
|
1767 |
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
8227
diff
changeset
|
1768 |
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
8227
diff
changeset
|
1769 ngx_int_t |
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
8227
diff
changeset
|
1770 ngx_http_v3_parse_data(ngx_connection_t *c, ngx_http_v3_parse_data_t *st, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1771 ngx_buf_t *b) |
8295
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
8227
diff
changeset
|
1772 { |
8466
4fd709540daf
HTTP/3: put ngx_http_v3_parse_varlen_int() return code in variable.
Roman Arutyunyan <arut@nginx.com>
parents:
8465
diff
changeset
|
1773 ngx_int_t rc; |
8295
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
8227
diff
changeset
|
1774 enum { |
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
8227
diff
changeset
|
1775 sw_start = 0, |
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
8227
diff
changeset
|
1776 sw_type, |
8549
d70a38acaea0
HTTP/3: skip unknown frames on request stream.
Roman Arutyunyan <arut@nginx.com>
parents:
8497
diff
changeset
|
1777 sw_length, |
d70a38acaea0
HTTP/3: skip unknown frames on request stream.
Roman Arutyunyan <arut@nginx.com>
parents:
8497
diff
changeset
|
1778 sw_skip |
8295
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
8227
diff
changeset
|
1779 }; |
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
8227
diff
changeset
|
1780 |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1781 for ( ;; ) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1782 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1783 switch (st->state) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1784 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1785 case sw_start: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1786 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1787 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 parse data"); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1788 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1789 st->state = sw_type; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1790 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1791 /* fall through */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1792 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1793 case sw_type: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1794 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1795 rc = ngx_http_v3_parse_varlen_int(c, &st->vlint, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1796 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1797 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1798 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1799 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1800 st->type = st->vlint.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1801 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1802 if (st->type == NGX_HTTP_V3_FRAME_HEADERS) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1803 /* trailers */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1804 goto done; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1805 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1806 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1807 if (ngx_http_v3_is_v2_frame(st->type) |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1808 || st->type == NGX_HTTP_V3_FRAME_GOAWAY |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1809 || st->type == NGX_HTTP_V3_FRAME_SETTINGS |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1810 || st->type == NGX_HTTP_V3_FRAME_MAX_PUSH_ID |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1811 || st->type == NGX_HTTP_V3_FRAME_CANCEL_PUSH |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1812 || st->type == NGX_HTTP_V3_FRAME_PUSH_PROMISE) |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1813 { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1814 return NGX_HTTP_V3_ERR_FRAME_UNEXPECTED; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1815 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1816 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1817 st->state = sw_length; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1818 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1819 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1820 case sw_length: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1821 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1822 rc = ngx_http_v3_parse_varlen_int(c, &st->vlint, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1823 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1824 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1825 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1826 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1827 st->length = st->vlint.value; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1828 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1829 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1830 "http3 parse data type:%ui, len:%ui", |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1831 st->type, st->length); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1832 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1833 if (st->type != NGX_HTTP_V3_FRAME_DATA && st->length > 0) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1834 st->state = sw_skip; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1835 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1836 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1837 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1838 st->state = sw_type; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1839 return NGX_OK; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1840 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1841 case sw_skip: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1842 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1843 rc = ngx_http_v3_parse_skip(b, &st->length); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1844 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1845 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1846 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1847 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1848 st->state = sw_type; |
8549
d70a38acaea0
HTTP/3: skip unknown frames on request stream.
Roman Arutyunyan <arut@nginx.com>
parents:
8497
diff
changeset
|
1849 break; |
d70a38acaea0
HTTP/3: skip unknown frames on request stream.
Roman Arutyunyan <arut@nginx.com>
parents:
8497
diff
changeset
|
1850 } |
8295
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
8227
diff
changeset
|
1851 } |
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
8227
diff
changeset
|
1852 |
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
8227
diff
changeset
|
1853 done: |
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
8227
diff
changeset
|
1854 |
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
8227
diff
changeset
|
1855 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 parse data done"); |
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
8227
diff
changeset
|
1856 |
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
8227
diff
changeset
|
1857 st->state = sw_start; |
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
8227
diff
changeset
|
1858 return NGX_DONE; |
5649079a41f4
Parsing HTTP/3 request body.
Roman Arutyunyan <arut@nginx.com>
parents:
8227
diff
changeset
|
1859 } |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1860 |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1861 |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1862 ngx_int_t |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1863 ngx_http_v3_parse_uni(ngx_connection_t *c, ngx_http_v3_parse_uni_t *st, |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1864 ngx_buf_t *b) |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1865 { |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1866 ngx_int_t rc; |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1867 enum { |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1868 sw_start = 0, |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1869 sw_type, |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1870 sw_control, |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1871 sw_encoder, |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1872 sw_decoder, |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1873 sw_unknown |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1874 }; |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1875 |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1876 for ( ;; ) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1877 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1878 switch (st->state) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1879 case sw_start: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1880 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1881 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 parse uni"); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1882 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1883 st->state = sw_type; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1884 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1885 /* fall through */ |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1886 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1887 case sw_type: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1888 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1889 rc = ngx_http_v3_parse_varlen_int(c, &st->vlint, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1890 if (rc != NGX_DONE) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1891 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1892 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1893 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1894 rc = ngx_http_v3_register_uni_stream(c, st->vlint.value); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1895 if (rc != NGX_OK) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1896 return rc; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1897 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1898 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1899 switch (st->vlint.value) { |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1900 case NGX_HTTP_V3_STREAM_CONTROL: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1901 st->state = sw_control; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1902 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1903 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1904 case NGX_HTTP_V3_STREAM_ENCODER: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1905 st->state = sw_encoder; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1906 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1907 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1908 case NGX_HTTP_V3_STREAM_DECODER: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1909 st->state = sw_decoder; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1910 break; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1911 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1912 default: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1913 st->state = sw_unknown; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1914 } |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1915 |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1916 break; |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1917 |
8838
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1918 case sw_control: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1919 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1920 return ngx_http_v3_parse_control(c, &st->u.control, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1921 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1922 case sw_encoder: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1923 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1924 return ngx_http_v3_parse_encoder(c, &st->u.encoder, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1925 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1926 case sw_decoder: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1927 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1928 return ngx_http_v3_parse_decoder(c, &st->u.decoder, b); |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1929 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1930 case sw_unknown: |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1931 |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1932 b->pos = b->last; |
d6e191a583cc
HTTP/3: bulk parse functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
1933 return NGX_AGAIN; |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1934 } |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1935 } |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
1936 } |