Mercurial > hg > nginx
annotate src/http/modules/ngx_http_range_filter_module.c @ 3496:fb88801564de
build nginx/Windows against OpenSSL-0.9.8n, since nginx-0.8.35
built against OpenSSL-1.0.0 crashed on Windows XP somewhere
in the NTDLL.DLL on the master process exit
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 21 Apr 2010 15:09:17 +0000 |
parents | e0bc43a52382 |
children | dd1570b6f237 |
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:
416
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:
416
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 |
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:
416
diff
changeset
|
4 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
416
diff
changeset
|
5 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
6 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_http.h> |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
12 /* |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
13 * the single part format: |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
14 * |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
15 * "HTTP/1.0 206 Partial Content" CRLF |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
16 * ... header ... |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
17 * "Content-Type: image/jpeg" CRLF |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
18 * "Content-Length: SIZE" CRLF |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
19 * "Content-Range: bytes START-END/SIZE" CRLF |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
20 * CRLF |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
21 * ... data ... |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
22 * |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
23 * |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
24 * the mutlipart format: |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
25 * |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
26 * "HTTP/1.0 206 Partial Content" CRLF |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
27 * ... header ... |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
28 * "Content-Type: multipart/byteranges; boundary=0123456789" CRLF |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
29 * CRLF |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
30 * CRLF |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
31 * "--0123456789" CRLF |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
32 * "Content-Type: image/jpeg" CRLF |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
33 * "Content-Range: bytes START0-END0/SIZE" CRLF |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
34 * CRLF |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
35 * ... data ... |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
36 * CRLF |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
37 * "--0123456789" CRLF |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
38 * "Content-Type: image/jpeg" CRLF |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
39 * "Content-Range: bytes START1-END1/SIZE" CRLF |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
40 * CRLF |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
41 * ... data ... |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
42 * CRLF |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
43 * "--0123456789--" CRLF |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
44 */ |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
45 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
46 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
47 typedef struct { |
963
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
48 off_t start; |
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
49 off_t end; |
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
50 ngx_str_t content_range; |
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
51 } ngx_http_range_t; |
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
52 |
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
53 |
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
54 typedef struct { |
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
55 off_t offset; |
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
56 ngx_str_t boundary_header; |
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
57 ngx_array_t ranges; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
58 } ngx_http_range_filter_ctx_t; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
59 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
60 |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
61 ngx_int_t ngx_http_range_parse(ngx_http_request_t *r, |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
62 ngx_http_range_filter_ctx_t *ctx); |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
63 static ngx_int_t ngx_http_range_singlepart_header(ngx_http_request_t *r, |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
64 ngx_http_range_filter_ctx_t *ctx); |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
65 static ngx_int_t ngx_http_range_multipart_header(ngx_http_request_t *r, |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
66 ngx_http_range_filter_ctx_t *ctx); |
2121
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
67 static ngx_int_t ngx_http_range_not_satisfiable(ngx_http_request_t *r); |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
68 static ngx_int_t ngx_http_range_test_overlapped(ngx_http_request_t *r, |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
69 ngx_http_range_filter_ctx_t *ctx, ngx_chain_t *in); |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
70 static ngx_int_t ngx_http_range_singlepart_body(ngx_http_request_t *r, |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
71 ngx_http_range_filter_ctx_t *ctx, ngx_chain_t *in); |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
72 static ngx_int_t ngx_http_range_multipart_body(ngx_http_request_t *r, |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
73 ngx_http_range_filter_ctx_t *ctx, ngx_chain_t *in); |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
74 |
681 | 75 static ngx_int_t ngx_http_range_header_filter_init(ngx_conf_t *cf); |
76 static ngx_int_t ngx_http_range_body_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
|
77 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
78 |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
79 static ngx_http_module_t ngx_http_range_header_filter_module_ctx = { |
509 | 80 NULL, /* preconfiguration */ |
681 | 81 ngx_http_range_header_filter_init, /* postconfiguration */ |
177
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
165
diff
changeset
|
82 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
83 NULL, /* create main configuration */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
84 NULL, /* init main configuration */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
85 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
86 NULL, /* create server configuration */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
87 NULL, /* merge server configuration */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
88 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
89 NULL, /* create location configuration */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
90 NULL, /* merge location configuration */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
91 }; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
92 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
93 |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
94 ngx_module_t ngx_http_range_header_filter_module = { |
509 | 95 NGX_MODULE_V1, |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
96 &ngx_http_range_header_filter_module_ctx, /* module context */ |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
97 NULL, /* module directives */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
98 NGX_HTTP_MODULE, /* module type */ |
541 | 99 NULL, /* init master */ |
681 | 100 NULL, /* init module */ |
541 | 101 NULL, /* init process */ |
102 NULL, /* init thread */ | |
103 NULL, /* exit thread */ | |
104 NULL, /* exit process */ | |
105 NULL, /* exit master */ | |
106 NGX_MODULE_V1_PADDING | |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
107 }; |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
108 |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
109 |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
110 static ngx_http_module_t ngx_http_range_body_filter_module_ctx = { |
509 | 111 NULL, /* preconfiguration */ |
681 | 112 ngx_http_range_body_filter_init, /* postconfiguration */ |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
113 |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
114 NULL, /* create main configuration */ |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
115 NULL, /* init main configuration */ |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
116 |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
117 NULL, /* create server configuration */ |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
118 NULL, /* merge server configuration */ |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
119 |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
120 NULL, /* create location configuration */ |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
121 NULL, /* merge location configuration */ |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
122 }; |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
123 |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
124 |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
125 ngx_module_t ngx_http_range_body_filter_module = { |
509 | 126 NGX_MODULE_V1, |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
127 &ngx_http_range_body_filter_module_ctx, /* module context */ |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
128 NULL, /* module directives */ |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
129 NGX_HTTP_MODULE, /* module type */ |
541 | 130 NULL, /* init master */ |
681 | 131 NULL, /* init module */ |
541 | 132 NULL, /* init process */ |
133 NULL, /* init thread */ | |
134 NULL, /* exit thread */ | |
135 NULL, /* exit process */ | |
136 NULL, /* exit master */ | |
137 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
|
138 }; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
139 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
140 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
141 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
|
142 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
|
143 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
144 |
493 | 145 static ngx_int_t |
146 ngx_http_range_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
|
147 { |
1630 | 148 time_t if_range; |
461 | 149 ngx_int_t rc; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
150 ngx_http_range_filter_ctx_t *ctx; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
151 |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
152 if (r->http_version < NGX_HTTP_VERSION_10 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
153 || 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
|
154 || r != r->main |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
136
diff
changeset
|
155 || r->headers_out.content_length_n == -1 |
581 | 156 || !r->allow_ranges) |
117
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
157 { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
158 return ngx_http_next_header_filter(r); |
117
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
159 } |
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
160 |
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
161 if (r->headers_in.range == NULL |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
162 || r->headers_in.range->value.len < 7 |
1107
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
1093
diff
changeset
|
163 || ngx_strncasecmp(r->headers_in.range->value.data, |
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
1093
diff
changeset
|
164 (u_char *) "bytes=", 6) |
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
1093
diff
changeset
|
165 != 0) |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
166 { |
1630 | 167 goto next_filter; |
168 } | |
169 | |
170 if (r->headers_in.if_range && r->headers_out.last_modified_time != -1) { | |
171 | |
172 if_range = ngx_http_parse_time(r->headers_in.if_range->value.data, | |
173 r->headers_in.if_range->value.len); | |
117
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
174 |
1630 | 175 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
176 "http ir:%d lm:%d", | |
177 if_range, r->headers_out.last_modified_time); | |
117
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
178 |
1630 | 179 if (if_range != r->headers_out.last_modified_time) { |
180 goto next_filter; | |
181 } | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
182 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
183 |
963
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
184 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_range_filter_ctx_t)); |
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
185 if (ctx == NULL) { |
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
186 return NGX_ERROR; |
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
187 } |
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
188 |
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
189 if (ngx_array_init(&ctx->ranges, r->pool, 1, sizeof(ngx_http_range_t)) |
2536
a6d6d762c554
small optimization: " == NGX_ERROR" > " != NGX_OK"
Igor Sysoev <igor@sysoev.ru>
parents:
2269
diff
changeset
|
190 != NGX_OK) |
461 | 191 { |
192 return NGX_ERROR; | |
193 } | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
194 |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
195 rc = ngx_http_range_parse(r, ctx); |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
196 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
197 if (rc == NGX_OK) { |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
198 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
199 ngx_http_set_ctx(r, ctx, ngx_http_range_body_filter_module); |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
200 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
201 r->headers_out.status = NGX_HTTP_PARTIAL_CONTENT; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
202 r->headers_out.status_line.len = 0; |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
203 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
204 if (ctx->ranges.nelts == 1) { |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
205 return ngx_http_range_singlepart_header(r, ctx); |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
206 } |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
207 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
208 return ngx_http_range_multipart_header(r, ctx); |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
209 } |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
210 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
211 if (rc == NGX_HTTP_RANGE_NOT_SATISFIABLE) { |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
212 return ngx_http_range_not_satisfiable(r); |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
213 } |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
214 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
215 /* rc == NGX_ERROR */ |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
216 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
217 return rc; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
218 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
219 next_filter: |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
220 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
221 r->headers_out.accept_ranges = ngx_list_push(&r->headers_out.headers); |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
222 if (r->headers_out.accept_ranges == NULL) { |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
223 return NGX_ERROR; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
224 } |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
225 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
226 r->headers_out.accept_ranges->hash = 1; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
227 r->headers_out.accept_ranges->key.len = sizeof("Accept-Ranges") - 1; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
228 r->headers_out.accept_ranges->key.data = (u_char *) "Accept-Ranges"; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
229 r->headers_out.accept_ranges->value.len = sizeof("bytes") - 1; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
230 r->headers_out.accept_ranges->value.data = (u_char *) "bytes"; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
231 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
232 return ngx_http_next_header_filter(r); |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
233 } |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
234 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
235 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
236 ngx_int_t |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
237 ngx_http_range_parse(ngx_http_request_t *r, ngx_http_range_filter_ctx_t *ctx) |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
238 { |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
239 u_char *p; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
240 off_t start, end; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
241 ngx_uint_t suffix; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
242 ngx_http_range_t *range; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
243 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
244 p = r->headers_in.range->value.data + 6; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
245 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
246 for ( ;; ) { |
231
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
247 start = 0; |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
248 end = 0; |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
249 suffix = 0; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
250 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
251 while (*p == ' ') { p++; } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
252 |
231
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
253 if (*p != '-') { |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
254 if (*p < '0' || *p > '9') { |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
255 return NGX_HTTP_RANGE_NOT_SATISFIABLE; |
231
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
256 } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
257 |
231
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
258 while (*p >= '0' && *p <= '9') { |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
259 start = start * 10 + *p++ - '0'; |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
260 } |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
261 |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
262 while (*p == ' ') { p++; } |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
263 |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
264 if (*p++ != '-') { |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
265 return NGX_HTTP_RANGE_NOT_SATISFIABLE; |
231
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
266 } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
267 |
231
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
268 if (start >= r->headers_out.content_length_n) { |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
269 return NGX_HTTP_RANGE_NOT_SATISFIABLE; |
231
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
270 } |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
271 |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
272 while (*p == ' ') { p++; } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
273 |
231
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
274 if (*p == ',' || *p == '\0') { |
963
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
275 range = ngx_array_push(&ctx->ranges); |
501 | 276 if (range == NULL) { |
461 | 277 return NGX_ERROR; |
278 } | |
279 | |
231
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
280 range->start = start; |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
281 range->end = r->headers_out.content_length_n; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
282 |
231
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
283 if (*p++ != ',') { |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
284 return NGX_OK; |
231
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
285 } |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
286 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
287 continue; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
288 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
289 |
231
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
290 } else { |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
291 suffix = 1; |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
292 p++; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
293 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
294 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
295 if (*p < '0' || *p > '9') { |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
296 return NGX_HTTP_RANGE_NOT_SATISFIABLE; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
297 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
298 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
299 while (*p >= '0' && *p <= '9') { |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
300 end = end * 10 + *p++ - '0'; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
301 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
302 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
303 while (*p == ' ') { p++; } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
304 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
305 if (*p != ',' && *p != '\0') { |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
306 return NGX_HTTP_RANGE_NOT_SATISFIABLE; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
307 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
308 |
231
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
309 if (suffix) { |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
310 start = r->headers_out.content_length_n - end; |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
311 end = r->headers_out.content_length_n - 1; |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
312 } |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
313 |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
314 if (start > end) { |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
315 return NGX_HTTP_RANGE_NOT_SATISFIABLE; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
316 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
317 |
963
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
318 range = ngx_array_push(&ctx->ranges); |
501 | 319 if (range == NULL) { |
461 | 320 return NGX_ERROR; |
321 } | |
322 | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
323 range->start = start; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
324 |
231
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
325 if (end >= r->headers_out.content_length_n) { |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
326 /* |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
327 * Download Accelerator sends the last byte position |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
328 * that equals to the file length |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
329 */ |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
330 range->end = r->headers_out.content_length_n; |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
331 |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
332 } else { |
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
333 range->end = end + 1; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
334 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
335 |
231
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
336 if (*p++ != ',') { |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
337 return NGX_OK; |
231
92db0aa1e83f
nginx-0.0.1-2004-01-16-21:29:15 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
338 } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
339 } |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
340 } |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
341 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
342 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
343 static ngx_int_t |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
344 ngx_http_range_singlepart_header(ngx_http_request_t *r, |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
345 ngx_http_range_filter_ctx_t *ctx) |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
346 { |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
347 ngx_table_elt_t *content_range; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
348 ngx_http_range_t *range; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
349 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
350 content_range = ngx_list_push(&r->headers_out.headers); |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
351 if (content_range == NULL) { |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
352 return NGX_ERROR; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
353 } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
354 |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
355 r->headers_out.content_range = content_range; |
461 | 356 |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
357 content_range->hash = 1; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
358 content_range->key.len = sizeof("Content-Range") - 1; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
359 content_range->key.data = (u_char *) "Content-Range"; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
360 |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
361 content_range->value.data = ngx_pnalloc(r->pool, |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
362 sizeof("bytes -/") - 1 + 3 * NGX_OFF_T_LEN); |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
363 if (content_range->value.data == NULL) { |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
364 return NGX_ERROR; |
461 | 365 } |
366 | |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
367 /* "Content-Range: bytes SSSS-EEEE/TTTT" header */ |
461 | 368 |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
369 range = ctx->ranges.elts; |
461 | 370 |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
371 content_range->value.len = ngx_sprintf(content_range->value.data, |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
372 "bytes %O-%O/%O", |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
373 range->start, range->end - 1, |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
374 r->headers_out.content_length_n) |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
375 - content_range->value.data; |
461 | 376 |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
377 r->headers_out.content_length_n = range->end - range->start; |
461 | 378 |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
379 if (r->headers_out.content_length) { |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
380 r->headers_out.content_length->hash = 0; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
381 r->headers_out.content_length = NULL; |
461 | 382 } |
383 | |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
384 return ngx_http_next_header_filter(r); |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
385 } |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
386 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
387 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
388 static ngx_int_t |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
389 ngx_http_range_multipart_header(ngx_http_request_t *r, |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
390 ngx_http_range_filter_ctx_t *ctx) |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
391 { |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
392 size_t len; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
393 ngx_uint_t i; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
394 ngx_http_range_t *range; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
395 ngx_atomic_uint_t boundary; |
461 | 396 |
493 | 397 len = sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN |
398 + sizeof(CRLF "Content-Type: ") - 1 | |
509 | 399 + r->headers_out.content_type.len |
461 | 400 + sizeof(CRLF "Content-Range: bytes ") - 1; |
401 | |
402 if (r->headers_out.charset.len) { | |
403 len += sizeof("; charset=") - 1 + r->headers_out.charset.len; | |
404 } | |
405 | |
2049 | 406 ctx->boundary_header.data = ngx_pnalloc(r->pool, len); |
501 | 407 if (ctx->boundary_header.data == NULL) { |
461 | 408 return NGX_ERROR; |
409 } | |
410 | |
493 | 411 boundary = ngx_next_temp_number(0); |
461 | 412 |
413 /* | |
414 * The boundary header of the range: | |
415 * CRLF | |
416 * "--0123456789" CRLF | |
417 * "Content-Type: image/jpeg" CRLF | |
418 * "Content-Range: bytes " | |
419 */ | |
420 | |
421 if (r->headers_out.charset.len) { | |
422 ctx->boundary_header.len = ngx_sprintf(ctx->boundary_header.data, | |
493 | 423 CRLF "--%0muA" CRLF |
461 | 424 "Content-Type: %V; charset=%V" CRLF |
425 "Content-Range: bytes ", | |
426 boundary, | |
509 | 427 &r->headers_out.content_type, |
461 | 428 &r->headers_out.charset) |
429 - ctx->boundary_header.data; | |
430 | |
431 r->headers_out.charset.len = 0; | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
432 |
2119
0799703985ef
fix ranges without Content-Type
Igor Sysoev <igor@sysoev.ru>
parents:
2118
diff
changeset
|
433 } else if (r->headers_out.content_type.len) { |
461 | 434 ctx->boundary_header.len = ngx_sprintf(ctx->boundary_header.data, |
493 | 435 CRLF "--%0muA" CRLF |
461 | 436 "Content-Type: %V" CRLF |
437 "Content-Range: bytes ", | |
438 boundary, | |
509 | 439 &r->headers_out.content_type) |
461 | 440 - ctx->boundary_header.data; |
2119
0799703985ef
fix ranges without Content-Type
Igor Sysoev <igor@sysoev.ru>
parents:
2118
diff
changeset
|
441 |
0799703985ef
fix ranges without Content-Type
Igor Sysoev <igor@sysoev.ru>
parents:
2118
diff
changeset
|
442 } else { |
0799703985ef
fix ranges without Content-Type
Igor Sysoev <igor@sysoev.ru>
parents:
2118
diff
changeset
|
443 ctx->boundary_header.len = ngx_sprintf(ctx->boundary_header.data, |
0799703985ef
fix ranges without Content-Type
Igor Sysoev <igor@sysoev.ru>
parents:
2118
diff
changeset
|
444 CRLF "--%0muA" CRLF |
0799703985ef
fix ranges without Content-Type
Igor Sysoev <igor@sysoev.ru>
parents:
2118
diff
changeset
|
445 "Content-Range: bytes ", |
0799703985ef
fix ranges without Content-Type
Igor Sysoev <igor@sysoev.ru>
parents:
2118
diff
changeset
|
446 boundary) |
0799703985ef
fix ranges without Content-Type
Igor Sysoev <igor@sysoev.ru>
parents:
2118
diff
changeset
|
447 - ctx->boundary_header.data; |
461 | 448 } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
449 |
509 | 450 r->headers_out.content_type.data = |
2049 | 451 ngx_pnalloc(r->pool, |
452 sizeof("Content-Type: multipart/byteranges; boundary=") - 1 | |
453 + NGX_ATOMIC_T_LEN); | |
165
894a01c6aea3
nginx-0.0.1-2003-10-29-20:39:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
164
diff
changeset
|
454 |
509 | 455 if (r->headers_out.content_type.data == NULL) { |
461 | 456 return NGX_ERROR; |
457 } | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
458 |
2882
896db5a09bd2
reset content_type hash value, this fixes a bug when XSLT responses
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
459 r->headers_out.content_type_lowcase = NULL; |
896db5a09bd2
reset content_type hash value, this fixes a bug when XSLT responses
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
460 |
461 | 461 /* "Content-Type: multipart/byteranges; boundary=0123456789" */ |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
462 |
509 | 463 r->headers_out.content_type.len = |
464 ngx_sprintf(r->headers_out.content_type.data, | |
493 | 465 "multipart/byteranges; boundary=%0muA", |
461 | 466 boundary) |
509 | 467 - r->headers_out.content_type.data; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
468 |
2882
896db5a09bd2
reset content_type hash value, this fixes a bug when XSLT responses
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
469 r->headers_out.content_type_len = r->headers_out.content_type.len; |
493 | 470 |
461 | 471 /* the size of the last boundary CRLF "--0123456789--" CRLF */ |
493 | 472 |
473 len = sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN + sizeof("--" CRLF) - 1; | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
474 |
963
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
475 range = ctx->ranges.elts; |
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
476 for (i = 0; i < ctx->ranges.nelts; i++) { |
455 | 477 |
461 | 478 /* the size of the range: "SSSS-EEEE/TTTT" CRLF CRLF */ |
455 | 479 |
461 | 480 range[i].content_range.data = |
2049 | 481 ngx_pnalloc(r->pool, 3 * NGX_OFF_T_LEN + 2 + 4); |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
482 |
461 | 483 if (range[i].content_range.data == NULL) { |
484 return NGX_ERROR; | |
485 } | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
486 |
461 | 487 range[i].content_range.len = ngx_sprintf(range[i].content_range.data, |
488 "%O-%O/%O" CRLF CRLF, | |
489 range[i].start, range[i].end - 1, | |
490 r->headers_out.content_length_n) | |
491 - range[i].content_range.data; | |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
492 |
461 | 493 len += ctx->boundary_header.len + range[i].content_range.len |
494 + (size_t) (range[i].end - range[i].start); | |
495 } | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
496 |
461 | 497 r->headers_out.content_length_n = len; |
960 | 498 |
499 if (r->headers_out.content_length) { | |
500 r->headers_out.content_length->hash = 0; | |
501 r->headers_out.content_length = NULL; | |
502 } | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
503 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
504 return ngx_http_next_header_filter(r); |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
505 } |
1630 | 506 |
507 | |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
508 static ngx_int_t |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
509 ngx_http_range_not_satisfiable(ngx_http_request_t *r) |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
510 { |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
511 ngx_table_elt_t *content_range; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
512 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
513 r->headers_out.status = NGX_HTTP_RANGE_NOT_SATISFIABLE; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
514 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
515 content_range = ngx_list_push(&r->headers_out.headers); |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
516 if (content_range == NULL) { |
1630 | 517 return NGX_ERROR; |
518 } | |
519 | |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
520 r->headers_out.content_range = content_range; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
521 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
522 content_range->hash = 1; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
523 content_range->key.len = sizeof("Content-Range") - 1; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
524 content_range->key.data = (u_char *) "Content-Range"; |
1630 | 525 |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
526 content_range->value.data = ngx_pnalloc(r->pool, |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
527 sizeof("bytes */") - 1 + NGX_OFF_T_LEN); |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
528 if (content_range->value.data == NULL) { |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
529 return NGX_ERROR; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
530 } |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
531 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
532 content_range->value.len = ngx_sprintf(content_range->value.data, |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
533 "bytes */%O", |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
534 r->headers_out.content_length_n) |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
535 - content_range->value.data; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
536 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
537 ngx_http_clear_content_length(r); |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
538 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
539 return NGX_HTTP_RANGE_NOT_SATISFIABLE; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
540 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
541 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
542 |
493 | 543 static ngx_int_t |
544 ngx_http_range_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
|
545 { |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
546 ngx_http_range_filter_ctx_t *ctx; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
547 |
963
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
548 if (in == NULL) { |
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
549 return ngx_http_next_body_filter(r, in); |
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
550 } |
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
551 |
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
552 ctx = ngx_http_get_module_ctx(r, ngx_http_range_body_filter_module); |
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
553 |
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
554 if (ctx == NULL) { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
555 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
|
556 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
557 |
2121
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
558 if (ctx->ranges.nelts == 1) { |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
559 return ngx_http_range_singlepart_body(r, ctx, in); |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
560 } |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
561 |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
562 /* |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
563 * multipart ranges are supported only if whole body is in a single buffer |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
564 */ |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
565 |
962
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
566 if (ngx_buf_special(in->buf)) { |
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
567 return ngx_http_next_body_filter(r, in); |
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
568 } |
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
569 |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
570 if (ngx_http_range_test_overlapped(r, ctx, in) != NGX_OK) { |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
571 return NGX_ERROR; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
572 } |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
573 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
574 return ngx_http_range_multipart_body(r, ctx, in); |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
575 } |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
576 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
577 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
578 static ngx_int_t |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
579 ngx_http_range_test_overlapped(ngx_http_request_t *r, |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
580 ngx_http_range_filter_ctx_t *ctx, ngx_chain_t *in) |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
581 { |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
582 off_t start, last; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
583 ngx_buf_t *buf; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
584 ngx_uint_t i; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
585 ngx_http_range_t *range; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
586 |
962
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
587 if (ctx->offset) { |
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
588 goto overlapped; |
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
589 } |
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
590 |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
591 buf = in->buf; |
960 | 592 |
593 if (!buf->last_buf) { | |
962
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
594 |
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
595 if (buf->in_file) { |
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
596 start = buf->file_pos + ctx->offset; |
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
597 last = buf->file_last + ctx->offset; |
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
598 |
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
599 } else { |
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
600 start = buf->pos - buf->start + ctx->offset; |
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
601 last = buf->last - buf->start + ctx->offset; |
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
602 } |
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
603 |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
604 range = ctx->ranges.elts; |
963
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
605 for (i = 0; i < ctx->ranges.nelts; i++) { |
962
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
606 if (start > range[i].start || last < range[i].end) { |
960 | 607 goto overlapped; |
608 } | |
609 } | |
610 } | |
611 | |
962
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
612 ctx->offset = ngx_buf_size(buf); |
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
613 |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
614 return NGX_OK; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
615 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
616 overlapped: |
960 | 617 |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
618 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
619 "range in overlapped buffers"); |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
620 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
621 return NGX_ERROR; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
622 } |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
623 |
962
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
624 |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
625 static ngx_int_t |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
626 ngx_http_range_singlepart_body(ngx_http_request_t *r, |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
627 ngx_http_range_filter_ctx_t *ctx, ngx_chain_t *in) |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
628 { |
2121
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
629 off_t start, last; |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
630 ngx_buf_t *buf; |
2121
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
631 ngx_chain_t *out, *cl, **ll; |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
632 ngx_http_range_t *range; |
960 | 633 |
2121
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
634 out = NULL; |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
635 ll = &out; |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
636 range = ctx->ranges.elts; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
637 |
2121
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
638 for (cl = in; cl; cl = cl->next) { |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
639 |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
640 buf = cl->buf; |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
641 |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
642 start = ctx->offset; |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
643 last = ctx->offset + ngx_buf_size(buf); |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
644 |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
645 ctx->offset = last; |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
646 |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
647 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
648 "http range body buf: %O-%O", start, last); |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
649 |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
650 if (ngx_buf_special(buf)) { |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
651 *ll = cl; |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
652 ll = &cl->next; |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
653 continue; |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
654 } |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
655 |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
656 if (range->end <= start || range->start >= last) { |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
657 |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
658 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
659 "http range body skip"); |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
660 |
2269 | 661 if (buf->in_file) { |
662 buf->file_pos = buf->file_last; | |
663 } | |
664 | |
2121
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
665 buf->pos = buf->last; |
2269 | 666 buf->sync = 1; |
667 | |
2121
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
668 continue; |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
669 } |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
670 |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
671 if (range->start > start) { |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
672 |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
673 if (buf->in_file) { |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
674 buf->file_pos += range->start - start; |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
675 } |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
676 |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
677 if (ngx_buf_in_memory(buf)) { |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
678 buf->pos += (size_t) (range->start - start); |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
679 } |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
680 } |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
681 |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
682 if (range->end <= last) { |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
683 |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
684 if (buf->in_file) { |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
685 buf->file_last -= last - range->end; |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
686 } |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
687 |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
688 if (ngx_buf_in_memory(buf)) { |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
689 buf->last -= (size_t) (last - range->end); |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
690 } |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
691 |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
692 buf->last_buf = 1; |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
693 *ll = cl; |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
694 cl->next = NULL; |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
695 |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
696 break; |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
697 } |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
698 |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
699 *ll = cl; |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
700 ll = &cl->next; |
960 | 701 } |
702 | |
2121
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
703 if (out == NULL) { |
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
704 return NGX_OK; |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
705 } |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
706 |
2121
b39c0040b3e4
support several buf's for single-part range
Igor Sysoev <igor@sysoev.ru>
parents:
2119
diff
changeset
|
707 return ngx_http_next_body_filter(r, out); |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
708 } |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
709 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
710 |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
711 static ngx_int_t |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
712 ngx_http_range_multipart_body(ngx_http_request_t *r, |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
713 ngx_http_range_filter_ctx_t *ctx, ngx_chain_t *in) |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
714 { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
715 off_t body_start; |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
716 ngx_buf_t *b, *buf; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
717 ngx_uint_t i; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
718 ngx_chain_t *out, *hcl, *rcl, *dcl, **ll; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
719 ngx_http_range_t *range; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
720 |
960 | 721 ll = &out; |
2118
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
722 buf = in->buf; |
c1f589732d8c
split ngx_http_range_filter_module
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
723 range = ctx->ranges.elts; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
724 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
725 #if (NGX_HTTP_CACHE) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
726 body_start = r->cached ? r->cache->body_start : 0; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
727 #else |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
728 body_start = 0; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
729 #endif |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
730 |
963
78e70dae89f0
move ranges array to ngx_http_range_filter_ctx_t
Igor Sysoev <igor@sysoev.ru>
parents:
962
diff
changeset
|
731 for (i = 0; i < ctx->ranges.nelts; i++) { |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
732 |
960 | 733 /* |
734 * The boundary header of the range: | |
735 * CRLF | |
736 * "--0123456789" CRLF | |
737 * "Content-Type: image/jpeg" CRLF | |
738 * "Content-Range: bytes " | |
739 */ | |
740 | |
741 b = ngx_calloc_buf(r->pool); | |
742 if (b == NULL) { | |
743 return NGX_ERROR; | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
744 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
745 |
960 | 746 b->memory = 1; |
747 b->pos = ctx->boundary_header.data; | |
748 b->last = ctx->boundary_header.data + ctx->boundary_header.len; | |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
749 |
960 | 750 hcl = ngx_alloc_chain_link(r->pool); |
751 if (hcl == NULL) { | |
752 return NGX_ERROR; | |
753 } | |
461 | 754 |
960 | 755 hcl->buf = b; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
756 |
461 | 757 |
960 | 758 /* "SSSS-EEEE/TTTT" CRLF CRLF */ |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
759 |
501 | 760 b = ngx_calloc_buf(r->pool); |
761 if (b == NULL) { | |
461 | 762 return NGX_ERROR; |
763 } | |
764 | |
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:
335
diff
changeset
|
765 b->temporary = 1; |
960 | 766 b->pos = range[i].content_range.data; |
767 b->last = range[i].content_range.data + range[i].content_range.len; | |
768 | |
769 rcl = ngx_alloc_chain_link(r->pool); | |
770 if (rcl == NULL) { | |
771 return NGX_ERROR; | |
772 } | |
773 | |
774 rcl->buf = b; | |
775 | |
776 | |
777 /* the range data */ | |
461 | 778 |
960 | 779 b = ngx_calloc_buf(r->pool); |
780 if (b == NULL) { | |
781 return NGX_ERROR; | |
782 } | |
783 | |
962
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
784 b->in_file = buf->in_file; |
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
785 b->temporary = buf->temporary; |
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
786 b->memory = buf->memory; |
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
787 b->mmap = buf->mmap; |
960 | 788 b->file = buf->file; |
789 | |
962
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
790 if (buf->in_file) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
791 b->file_pos = body_start + range[i].start; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
792 b->file_last = body_start + range[i].end; |
962
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
793 } |
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
794 |
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
795 if (ngx_buf_in_memory(buf)) { |
1093 | 796 b->pos = buf->start + (size_t) range[i].start; |
797 b->last = buf->start + (size_t) range[i].end; | |
962
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
798 } |
69754fb59ba1
support ranges for single memory buffer
Igor Sysoev <igor@sysoev.ru>
parents:
961
diff
changeset
|
799 |
960 | 800 dcl = ngx_alloc_chain_link(r->pool); |
801 if (dcl == NULL) { | |
461 | 802 return NGX_ERROR; |
803 } | |
804 | |
960 | 805 dcl->buf = b; |
461 | 806 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
807 *ll = hcl; |
960 | 808 hcl->next = rcl; |
809 rcl->next = dcl; | |
810 ll = &dcl->next; | |
811 } | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
812 |
960 | 813 /* the last boundary CRLF "--0123456789--" CRLF */ |
814 | |
815 b = ngx_calloc_buf(r->pool); | |
816 if (b == NULL) { | |
817 return NGX_ERROR; | |
818 } | |
819 | |
820 b->temporary = 1; | |
821 b->last_buf = 1; | |
822 | |
2049 | 823 b->pos = ngx_pnalloc(r->pool, sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN |
824 + sizeof("--" CRLF) - 1); | |
960 | 825 if (b->pos == NULL) { |
826 return NGX_ERROR; | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
827 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
828 |
1195
4ba6df5d5b53
fix multipart ranges trailing
Igor Sysoev <igor@sysoev.ru>
parents:
1107
diff
changeset
|
829 b->last = ngx_cpymem(b->pos, ctx->boundary_header.data, |
4ba6df5d5b53
fix multipart ranges trailing
Igor Sysoev <igor@sysoev.ru>
parents:
1107
diff
changeset
|
830 sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN); |
960 | 831 *b->last++ = '-'; *b->last++ = '-'; |
832 *b->last++ = CR; *b->last++ = LF; | |
833 | |
834 hcl = ngx_alloc_chain_link(r->pool); | |
835 if (hcl == NULL) { | |
836 return NGX_ERROR; | |
837 } | |
838 | |
839 hcl->buf = b; | |
840 hcl->next = NULL; | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
841 |
960 | 842 *ll = hcl; |
843 | |
844 return 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
|
845 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
846 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
847 |
493 | 848 static ngx_int_t |
681 | 849 ngx_http_range_header_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
|
850 { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
851 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
|
852 ngx_http_top_header_filter = ngx_http_range_header_filter; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
853 |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
854 return NGX_OK; |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
855 } |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
856 |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
857 |
493 | 858 static ngx_int_t |
681 | 859 ngx_http_range_body_filter_init(ngx_conf_t *cf) |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
860 { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
153
diff
changeset
|
861 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
|
862 ngx_http_top_body_filter = ngx_http_range_body_filter; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
863 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
864 return NGX_OK; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
865 } |