Mercurial > hg > nginx-quic
annotate src/http/modules/ngx_http_chunked_filter_module.c @ 7154:595a3de03e91
Xslt: fixed parameters parsing (ticket #1416).
If parameters were specified in xslt_stylesheet without variables,
any request except the first would cause an internal server error.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Thu, 16 Nov 2017 13:20:47 +0300 |
parents | 1b068a4e82d8 |
children | 46e3542d51b3 |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
356
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
356
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
356
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
356
diff
changeset
|
6 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_core.h> |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 #include <ngx_http.h> |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
4113
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
13 typedef struct { |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
14 ngx_chain_t *free; |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
15 ngx_chain_t *busy; |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
16 } ngx_http_chunked_filter_ctx_t; |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
17 |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
18 |
681 | 19 static ngx_int_t ngx_http_chunked_filter_init(ngx_conf_t *cf); |
7034
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
20 static ngx_chain_t *ngx_http_chunked_create_trailers(ngx_http_request_t *r, |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
21 ngx_http_chunked_filter_ctx_t *ctx); |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
22 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
23 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
24 static ngx_http_module_t ngx_http_chunked_filter_module_ctx = { |
509 | 25 NULL, /* preconfiguration */ |
681 | 26 ngx_http_chunked_filter_init, /* postconfiguration */ |
177
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
27 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
28 NULL, /* create main configuration */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
29 NULL, /* init main configuration */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
30 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
31 NULL, /* create server configuration */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
32 NULL, /* merge server configuration */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
33 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
34 NULL, /* create location configuration */ |
629 | 35 NULL /* merge location configuration */ |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
36 }; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
37 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
38 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
39 ngx_module_t ngx_http_chunked_filter_module = { |
509 | 40 NGX_MODULE_V1, |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
41 &ngx_http_chunked_filter_module_ctx, /* module context */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
42 NULL, /* module directives */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
43 NGX_HTTP_MODULE, /* module type */ |
541 | 44 NULL, /* init master */ |
681 | 45 NULL, /* init module */ |
541 | 46 NULL, /* init process */ |
47 NULL, /* init thread */ | |
48 NULL, /* exit thread */ | |
49 NULL, /* exit process */ | |
50 NULL, /* exit master */ | |
51 NGX_MODULE_V1_PADDING | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
52 }; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
53 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
54 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
55 static ngx_http_output_header_filter_pt ngx_http_next_header_filter; |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
56 static ngx_http_output_body_filter_pt ngx_http_next_body_filter; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
57 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
58 |
501 | 59 static ngx_int_t |
60 ngx_http_chunked_header_filter(ngx_http_request_t *r) | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
61 { |
4113
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
62 ngx_http_core_loc_conf_t *clcf; |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
63 ngx_http_chunked_filter_ctx_t *ctx; |
3484 | 64 |
615 | 65 if (r->headers_out.status == NGX_HTTP_NOT_MODIFIED |
66 || r->headers_out.status == NGX_HTTP_NO_CONTENT | |
5072
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
67 || r->headers_out.status < NGX_HTTP_OK |
3331
e0bc43a52382
backout r3325: postpone filter is a body only filter
Igor Sysoev <igor@sysoev.ru>
parents:
3324
diff
changeset
|
68 || r != r->main |
6306
b1858fc47e3b
Style: unified request method checks.
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
69 || r->method == NGX_HTTP_HEAD) |
615 | 70 { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
71 return ngx_http_next_header_filter(r); |
135
e29909bd9b8a
nginx-0.0.1-2003-09-28-23:29:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
72 } |
e29909bd9b8a
nginx-0.0.1-2003-09-28-23:29:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
73 |
7034
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
74 if (r->headers_out.content_length_n == -1 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
75 || r->expect_trailers) |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
76 { |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
77 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
78 |
7034
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
79 if (r->http_version >= NGX_HTTP_VERSION_11 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
80 && clcf->chunked_transfer_encoding) |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
81 { |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
82 if (r->expect_trailers) { |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
83 ngx_http_clear_content_length(r); |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
84 } |
3484 | 85 |
7034
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
86 r->chunked = 1; |
4113
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
87 |
7034
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
88 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_chunked_filter_ctx_t)); |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
89 if (ctx == NULL) { |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
90 return NGX_ERROR; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
91 } |
4113
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
92 |
7034
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
93 ngx_http_set_ctx(r, ctx, ngx_http_chunked_filter_module); |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
94 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
95 } else if (r->headers_out.content_length_n == -1) { |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
96 r->keepalive = 0; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
97 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
98 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
99 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
100 return ngx_http_next_header_filter(r); |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
101 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
102 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
103 |
501 | 104 static ngx_int_t |
105 ngx_http_chunked_body_filter(ngx_http_request_t *r, ngx_chain_t *in) | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
106 { |
4113
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
107 u_char *chunk; |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
108 off_t size; |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
109 ngx_int_t rc; |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
110 ngx_buf_t *b; |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
111 ngx_chain_t *out, *cl, *tl, **ll; |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
112 ngx_http_chunked_filter_ctx_t *ctx; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
113 |
483 | 114 if (in == NULL || !r->chunked || r->header_only) { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
115 return ngx_http_next_body_filter(r, in); |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
116 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
117 |
4113
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
118 ctx = ngx_http_get_module_ctx(r, ngx_http_chunked_filter_module); |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
119 |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
120 out = NULL; |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
121 ll = &out; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
122 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
123 size = 0; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
124 cl = in; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
125 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
126 for ( ;; ) { |
336
ca9a7f8c86da
nginx-0.0.3-2004-05-18-19:29:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
292
diff
changeset
|
127 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
6480 | 128 "http chunk: %O", ngx_buf_size(cl->buf)); |
336
ca9a7f8c86da
nginx-0.0.3-2004-05-18-19:29:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
292
diff
changeset
|
129 |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
337
diff
changeset
|
130 size += ngx_buf_size(cl->buf); |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
131 |
667 | 132 if (cl->buf->flush |
133 || cl->buf->sync | |
134 || ngx_buf_in_memory(cl->buf) | |
135 || cl->buf->in_file) | |
136 { | |
501 | 137 tl = ngx_alloc_chain_link(r->pool); |
138 if (tl == NULL) { | |
461 | 139 return NGX_ERROR; |
140 } | |
141 | |
452 | 142 tl->buf = cl->buf; |
143 *ll = tl; | |
144 ll = &tl->next; | |
145 } | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
146 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
147 if (cl->next == NULL) { |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
148 break; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
149 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
150 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
151 cl = cl->next; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
152 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
153 |
336
ca9a7f8c86da
nginx-0.0.3-2004-05-18-19:29:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
292
diff
changeset
|
154 if (size) { |
4113
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
155 tl = ngx_chain_get_free_buf(r->pool, &ctx->free); |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
156 if (tl == NULL) { |
455 | 157 return NGX_ERROR; |
158 } | |
159 | |
4113
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
160 b = tl->buf; |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
161 chunk = b->start; |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
162 |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
163 if (chunk == NULL) { |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
164 /* the "0000000000000000" is 64-bit hexadecimal string */ |
501 | 165 |
4113
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
166 chunk = ngx_palloc(r->pool, sizeof("0000000000000000" CRLF) - 1); |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
167 if (chunk == NULL) { |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
168 return NGX_ERROR; |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
169 } |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
170 |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
171 b->start = chunk; |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
172 b->end = chunk + sizeof("0000000000000000" CRLF) - 1; |
455 | 173 } |
174 | |
4113
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
175 b->tag = (ngx_buf_tag_t) &ngx_http_chunked_filter_module; |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
176 b->memory = 0; |
455 | 177 b->temporary = 1; |
178 b->pos = chunk; | |
473 | 179 b->last = ngx_sprintf(chunk, "%xO" CRLF, size); |
455 | 180 |
4113
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
181 tl->next = out; |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
182 out = tl; |
336
ca9a7f8c86da
nginx-0.0.3-2004-05-18-19:29:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
292
diff
changeset
|
183 } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
184 |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
337
diff
changeset
|
185 if (cl->buf->last_buf) { |
7034
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
186 tl = ngx_http_chunked_create_trailers(r, ctx); |
4113
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
187 if (tl == NULL) { |
461 | 188 return NGX_ERROR; |
189 } | |
4128 | 190 |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
337
diff
changeset
|
191 cl->buf->last_buf = 0; |
336
ca9a7f8c86da
nginx-0.0.3-2004-05-18-19:29:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
292
diff
changeset
|
192 |
4113
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
193 *ll = tl; |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
194 |
336
ca9a7f8c86da
nginx-0.0.3-2004-05-18-19:29:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
292
diff
changeset
|
195 if (size == 0) { |
7034
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
196 tl->buf->pos += 2; |
336
ca9a7f8c86da
nginx-0.0.3-2004-05-18-19:29:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
292
diff
changeset
|
197 } |
ca9a7f8c86da
nginx-0.0.3-2004-05-18-19:29:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
292
diff
changeset
|
198 |
4113
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
199 } else if (size > 0) { |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
200 tl = ngx_chain_get_free_buf(r->pool, &ctx->free); |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
201 if (tl == NULL) { |
461 | 202 return NGX_ERROR; |
203 } | |
204 | |
4113
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
205 b = tl->buf; |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
206 |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
207 b->tag = (ngx_buf_tag_t) &ngx_http_chunked_filter_module; |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
208 b->temporary = 0; |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
337
diff
changeset
|
209 b->memory = 1; |
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
337
diff
changeset
|
210 b->pos = (u_char *) CRLF; |
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
337
diff
changeset
|
211 b->last = b->pos + 2; |
4113
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
212 |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
213 *ll = tl; |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
214 |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
215 } else { |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
216 *ll = NULL; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
217 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
218 |
4113
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
219 rc = ngx_http_next_body_filter(r, out); |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
220 |
4114
5db098f97e0e
API change: ngx_chain_update_chains() now requires pool.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4113
diff
changeset
|
221 ngx_chain_update_chains(r->pool, &ctx->free, &ctx->busy, &out, |
4113
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
222 (ngx_buf_tag_t) &ngx_http_chunked_filter_module); |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
223 |
a28ba1cdec27
Buffers reuse in chunked filter.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3484
diff
changeset
|
224 return rc; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
225 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
226 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
227 |
7034
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
228 static ngx_chain_t * |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
229 ngx_http_chunked_create_trailers(ngx_http_request_t *r, |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
230 ngx_http_chunked_filter_ctx_t *ctx) |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
231 { |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
232 size_t len; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
233 ngx_buf_t *b; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
234 ngx_uint_t i; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
235 ngx_chain_t *cl; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
236 ngx_list_part_t *part; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
237 ngx_table_elt_t *header; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
238 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
239 len = 0; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
240 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
241 part = &r->headers_out.trailers.part; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
242 header = part->elts; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
243 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
244 for (i = 0; /* void */; i++) { |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
245 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
246 if (i >= part->nelts) { |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
247 if (part->next == NULL) { |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
248 break; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
249 } |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
250 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
251 part = part->next; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
252 header = part->elts; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
253 i = 0; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
254 } |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
255 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
256 if (header[i].hash == 0) { |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
257 continue; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
258 } |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
259 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
260 len += header[i].key.len + sizeof(": ") - 1 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
261 + header[i].value.len + sizeof(CRLF) - 1; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
262 } |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
263 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
264 cl = ngx_chain_get_free_buf(r->pool, &ctx->free); |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
265 if (cl == NULL) { |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
266 return NULL; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
267 } |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
268 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
269 b = cl->buf; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
270 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
271 b->tag = (ngx_buf_tag_t) &ngx_http_chunked_filter_module; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
272 b->temporary = 0; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
273 b->memory = 1; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
274 b->last_buf = 1; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
275 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
276 if (len == 0) { |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
277 b->pos = (u_char *) CRLF "0" CRLF CRLF; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
278 b->last = b->pos + sizeof(CRLF "0" CRLF CRLF) - 1; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
279 return cl; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
280 } |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
281 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
282 len += sizeof(CRLF "0" CRLF CRLF) - 1; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
283 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
284 b->pos = ngx_palloc(r->pool, len); |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
285 if (b->pos == NULL) { |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
286 return NULL; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
287 } |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
288 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
289 b->last = b->pos; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
290 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
291 *b->last++ = CR; *b->last++ = LF; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
292 *b->last++ = '0'; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
293 *b->last++ = CR; *b->last++ = LF; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
294 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
295 part = &r->headers_out.trailers.part; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
296 header = part->elts; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
297 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
298 for (i = 0; /* void */; i++) { |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
299 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
300 if (i >= part->nelts) { |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
301 if (part->next == NULL) { |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
302 break; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
303 } |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
304 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
305 part = part->next; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
306 header = part->elts; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
307 i = 0; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
308 } |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
309 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
310 if (header[i].hash == 0) { |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
311 continue; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
312 } |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
313 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
314 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
315 "http trailer: \"%V: %V\"", |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
316 &header[i].key, &header[i].value); |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
317 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
318 b->last = ngx_copy(b->last, header[i].key.data, header[i].key.len); |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
319 *b->last++ = ':'; *b->last++ = ' '; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
320 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
321 b->last = ngx_copy(b->last, header[i].value.data, header[i].value.len); |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
322 *b->last++ = CR; *b->last++ = LF; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
323 } |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
324 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
325 *b->last++ = CR; *b->last++ = LF; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
326 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
327 return cl; |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
328 } |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
329 |
1b068a4e82d8
Added support for trailers in HTTP responses.
Piotr Sikora <piotrsikora@google.com>
parents:
6480
diff
changeset
|
330 |
501 | 331 static ngx_int_t |
681 | 332 ngx_http_chunked_filter_init(ngx_conf_t *cf) |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
333 { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
334 ngx_http_next_header_filter = ngx_http_top_header_filter; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
335 ngx_http_top_header_filter = ngx_http_chunked_header_filter; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
336 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
337 ngx_http_next_body_filter = ngx_http_top_body_filter; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
338 ngx_http_top_body_filter = ngx_http_chunked_body_filter; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
339 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
340 return NGX_OK; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
341 } |