Mercurial > hg > nginx-quic
comparison src/http/modules/ngx_http_chunked_filter_module.c @ 8237:1efee5e4194c quic
HTTP/3: introduced ngx_http_v3_filter.
The filter is responsible for creating HTTP/3 response header and body.
The change removes differences to the default branch for
ngx_http_chunked_filter_module and ngx_http_header_filter_module.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Fri, 27 Nov 2020 17:46:21 +0000 |
parents | b80d9179ba2a |
children |
comparison
equal
deleted
inserted
replaced
8236:e9bd4305e68b | 8237:1efee5e4194c |
---|---|
104 static ngx_int_t | 104 static ngx_int_t |
105 ngx_http_chunked_body_filter(ngx_http_request_t *r, ngx_chain_t *in) | 105 ngx_http_chunked_body_filter(ngx_http_request_t *r, ngx_chain_t *in) |
106 { | 106 { |
107 u_char *chunk; | 107 u_char *chunk; |
108 off_t size; | 108 off_t size; |
109 size_t n; | |
110 ngx_int_t rc; | 109 ngx_int_t rc; |
111 ngx_buf_t *b; | 110 ngx_buf_t *b; |
112 ngx_chain_t *out, *cl, *tl, **ll; | 111 ngx_chain_t *out, *cl, *tl, **ll; |
113 ngx_http_chunked_filter_ctx_t *ctx; | 112 ngx_http_chunked_filter_ctx_t *ctx; |
114 | 113 |
160 | 159 |
161 b = tl->buf; | 160 b = tl->buf; |
162 chunk = b->start; | 161 chunk = b->start; |
163 | 162 |
164 if (chunk == NULL) { | 163 if (chunk == NULL) { |
165 | 164 /* the "0000000000000000" is 64-bit hexadecimal string */ |
166 #if (NGX_HTTP_V3) | 165 |
167 if (r->http_version == NGX_HTTP_VERSION_30) { | 166 chunk = ngx_palloc(r->pool, sizeof("0000000000000000" CRLF) - 1); |
168 n = NGX_HTTP_V3_VARLEN_INT_LEN * 2; | |
169 | |
170 } else | |
171 #endif | |
172 { | |
173 /* the "0000000000000000" is 64-bit hexadecimal string */ | |
174 n = sizeof("0000000000000000" CRLF) - 1; | |
175 } | |
176 | |
177 chunk = ngx_palloc(r->pool, n); | |
178 if (chunk == NULL) { | 167 if (chunk == NULL) { |
179 return NGX_ERROR; | 168 return NGX_ERROR; |
180 } | 169 } |
181 | 170 |
182 b->start = chunk; | 171 b->start = chunk; |
183 b->end = chunk + n; | 172 b->end = chunk + sizeof("0000000000000000" CRLF) - 1; |
184 } | 173 } |
185 | 174 |
186 b->tag = (ngx_buf_tag_t) &ngx_http_chunked_filter_module; | 175 b->tag = (ngx_buf_tag_t) &ngx_http_chunked_filter_module; |
187 b->memory = 0; | 176 b->memory = 0; |
188 b->temporary = 1; | 177 b->temporary = 1; |
189 b->pos = chunk; | 178 b->pos = chunk; |
190 | 179 b->last = ngx_sprintf(chunk, "%xO" CRLF, size); |
191 #if (NGX_HTTP_V3) | |
192 if (r->http_version == NGX_HTTP_VERSION_30) { | |
193 b->last = (u_char *) ngx_http_v3_encode_varlen_int(chunk, | |
194 NGX_HTTP_V3_FRAME_DATA); | |
195 b->last = (u_char *) ngx_http_v3_encode_varlen_int(b->last, size); | |
196 | |
197 } else | |
198 #endif | |
199 { | |
200 b->last = ngx_sprintf(chunk, "%xO" CRLF, size); | |
201 } | |
202 | 180 |
203 tl->next = out; | 181 tl->next = out; |
204 out = tl; | 182 out = tl; |
205 } | 183 } |
206 | |
207 #if (NGX_HTTP_V3) | |
208 if (r->http_version == NGX_HTTP_VERSION_30) { | |
209 | |
210 if (cl->buf->last_buf) { | |
211 tl = ngx_http_v3_create_trailers(r); | |
212 if (tl == NULL) { | |
213 return NGX_ERROR; | |
214 } | |
215 | |
216 cl->buf->last_buf = 0; | |
217 | |
218 *ll = tl; | |
219 | |
220 } else { | |
221 *ll = NULL; | |
222 } | |
223 | |
224 } else | |
225 #endif | |
226 | 184 |
227 if (cl->buf->last_buf) { | 185 if (cl->buf->last_buf) { |
228 tl = ngx_http_chunked_create_trailers(r, ctx); | 186 tl = ngx_http_chunked_create_trailers(r, ctx); |
229 if (tl == NULL) { | 187 if (tl == NULL) { |
230 return NGX_ERROR; | 188 return NGX_ERROR; |