Mercurial > hg > nginx-quic
annotate src/http/modules/ngx_http_static_module.c @ 3938:1e90599af73b
use !aNULL to disable all anonymous cipher suites
patch by Rob Stradling
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 27 Jun 2011 15:47:51 +0000 |
parents | 84905c7b2aa7 |
children | 1a94a56a4e5d |
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 |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
6 |
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
87
5f6d848dcbef
nginx-0.0.1-2003-05-13-20:02:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
74
diff
changeset
|
8 #include <ngx_core.h> |
3
34a521b1a148
nginx-0.0.1-2002-08-20-18:48:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
9 #include <ngx_http.h> |
34a521b1a148
nginx-0.0.1-2002-08-20-18:48:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
10 |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
12 static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r); |
681 | 13 static ngx_int_t ngx_http_static_init(ngx_conf_t *cf); |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
14 |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
15 |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
16 ngx_http_module_t ngx_http_static_module_ctx = { |
509 | 17 NULL, /* preconfiguration */ |
681 | 18 ngx_http_static_init, /* postconfiguration */ |
177
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
176
diff
changeset
|
19 |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
20 NULL, /* create main configuration */ |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
21 NULL, /* init main configuration */ |
577 | 22 |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
23 NULL, /* create server configuration */ |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
24 NULL, /* merge server configuration */ |
577 | 25 |
1454 | 26 NULL, /* create location configuration */ |
27 NULL /* merge location configuration */ | |
577 | 28 }; |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
29 |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
30 |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
31 ngx_module_t ngx_http_static_module = { |
509 | 32 NGX_MODULE_V1, |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
33 &ngx_http_static_module_ctx, /* module context */ |
1454 | 34 NULL, /* module directives */ |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
35 NGX_HTTP_MODULE, /* module type */ |
541 | 36 NULL, /* init master */ |
681 | 37 NULL, /* init module */ |
541 | 38 NULL, /* init process */ |
39 NULL, /* init thread */ | |
40 NULL, /* exit thread */ | |
41 NULL, /* exit process */ | |
42 NULL, /* exit master */ | |
43 NGX_MODULE_V1_PADDING | |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
44 }; |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
45 |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
46 |
509 | 47 static ngx_int_t |
48 ngx_http_static_handler(ngx_http_request_t *r) | |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
49 { |
557 | 50 u_char *last, *location; |
2038
93a0d80fdce6
add args in redirect to a directory
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
51 size_t root, len; |
1454 | 52 ngx_str_t path; |
557 | 53 ngx_int_t rc; |
54 ngx_uint_t level; | |
55 ngx_log_t *log; | |
56 ngx_buf_t *b; | |
57 ngx_chain_t out; | |
1454 | 58 ngx_open_file_info_t of; |
557 | 59 ngx_http_core_loc_conf_t *clcf; |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
60 |
2182
23309bcd9937
allow file existence test for POST requests in static module
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
61 if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD|NGX_HTTP_POST))) { |
639 | 62 return NGX_HTTP_NOT_ALLOWED; |
63 } | |
64 | |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
65 if (r->uri.data[r->uri.len - 1] == '/') { |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
66 return NGX_DECLINED; |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
67 } |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
68 |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
69 log = r->connection->log; |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
70 |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
71 /* |
557 | 72 * ngx_http_map_uri_to_path() allocates memory for terminating '\0' |
73 * so we do not need to reserve memory for '/' for possible redirect | |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
74 */ |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
75 |
773 | 76 last = ngx_http_map_uri_to_path(r, &path, &root, 0); |
557 | 77 if (last == NULL) { |
78 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
400
69e851f83522
nginx-0.0.8-2004-07-26-20:21:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
79 } |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
80 |
1454 | 81 path.len = last - path.data; |
82 | |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
83 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, |
557 | 84 "http filename: \"%s\"", path.data); |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
85 |
1454 | 86 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
563 | 87 |
2068
75a8d34459c5
ngx_memzero() ngx_open_file_info_t
Igor Sysoev <igor@sysoev.ru>
parents:
2063
diff
changeset
|
88 ngx_memzero(&of, sizeof(ngx_open_file_info_t)); |
75a8d34459c5
ngx_memzero() ngx_open_file_info_t
Igor Sysoev <igor@sysoev.ru>
parents:
2063
diff
changeset
|
89 |
3178 | 90 of.read_ahead = clcf->read_ahead; |
2129 | 91 of.directio = clcf->directio; |
1767
c42431762903
open_file_cache_retest > open_file_cache_valid
Igor Sysoev <igor@sysoev.ru>
parents:
1696
diff
changeset
|
92 of.valid = clcf->open_file_cache_valid; |
1772 | 93 of.min_uses = clcf->open_file_cache_min_uses; |
1454 | 94 of.errors = clcf->open_file_cache_errors; |
1457 | 95 of.events = clcf->open_file_cache_events; |
1454 | 96 |
1799 | 97 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool) |
98 != NGX_OK) | |
99 { | |
1454 | 100 switch (of.err) { |
101 | |
102 case 0: | |
103 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
104 |
1454 | 105 case NGX_ENOENT: |
106 case NGX_ENOTDIR: | |
107 case NGX_ENAMETOOLONG: | |
108 | |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
165
diff
changeset
|
109 level = NGX_LOG_ERR; |
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
165
diff
changeset
|
110 rc = NGX_HTTP_NOT_FOUND; |
1454 | 111 break; |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
112 |
1454 | 113 case NGX_EACCES: |
114 | |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
165
diff
changeset
|
115 level = NGX_LOG_ERR; |
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
165
diff
changeset
|
116 rc = NGX_HTTP_FORBIDDEN; |
1454 | 117 break; |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
118 |
1454 | 119 default: |
120 | |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
165
diff
changeset
|
121 level = NGX_LOG_CRIT; |
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
165
diff
changeset
|
122 rc = NGX_HTTP_INTERNAL_SERVER_ERROR; |
1454 | 123 break; |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
124 } |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
165
diff
changeset
|
125 |
527 | 126 if (rc != NGX_HTTP_NOT_FOUND || clcf->log_not_found) { |
1454 | 127 ngx_log_error(level, log, of.err, |
2756
09cab3f8d92e
*) of.test_only to not open file if only stat() is enough
Igor Sysoev <igor@sysoev.ru>
parents:
2721
diff
changeset
|
128 "%s \"%s\" failed", of.failed, path.data); |
527 | 129 } |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
165
diff
changeset
|
130 |
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
165
diff
changeset
|
131 return rc; |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
132 } |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
133 |
2444
aee735f41627
set r->root_tested for non-error_page response only
Igor Sysoev <igor@sysoev.ru>
parents:
2403
diff
changeset
|
134 r->root_tested = !r->error_page; |
2087
c8039b26a949
always test root existence for access_log with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2068
diff
changeset
|
135 |
1696 | 136 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, "http static fd: %d", of.fd); |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
137 |
1454 | 138 if (of.is_dir) { |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
139 |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
140 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, log, 0, "http dir"); |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
141 |
509 | 142 r->headers_out.location = ngx_palloc(r->pool, sizeof(ngx_table_elt_t)); |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
143 if (r->headers_out.location == NULL) { |
165
894a01c6aea3
nginx-0.0.1-2003-10-29-20:39:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
144 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
894a01c6aea3
nginx-0.0.1-2003-10-29-20:39:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
145 } |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
146 |
2038
93a0d80fdce6
add args in redirect to a directory
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
147 len = r->uri.len + 1; |
93a0d80fdce6
add args in redirect to a directory
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
148 |
93a0d80fdce6
add args in redirect to a directory
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
149 if (!clcf->alias && clcf->root_lengths == NULL && r->args.len == 0) { |
557 | 150 location = path.data + clcf->root.len; |
151 | |
2038
93a0d80fdce6
add args in redirect to a directory
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
152 *last = '/'; |
93a0d80fdce6
add args in redirect to a directory
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
153 |
557 | 154 } else { |
2038
93a0d80fdce6
add args in redirect to a directory
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
155 if (r->args.len) { |
93a0d80fdce6
add args in redirect to a directory
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
156 len += r->args.len + 1; |
93a0d80fdce6
add args in redirect to a directory
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
157 } |
93a0d80fdce6
add args in redirect to a directory
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
158 |
2049 | 159 location = ngx_pnalloc(r->pool, len); |
557 | 160 if (location == NULL) { |
161 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
162 } | |
163 | |
573 | 164 last = ngx_copy(location, r->uri.data, r->uri.len); |
2038
93a0d80fdce6
add args in redirect to a directory
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
165 |
93a0d80fdce6
add args in redirect to a directory
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
166 *last = '/'; |
557 | 167 |
2038
93a0d80fdce6
add args in redirect to a directory
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
168 if (r->args.len) { |
93a0d80fdce6
add args in redirect to a directory
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
169 *++last = '?'; |
93a0d80fdce6
add args in redirect to a directory
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
170 ngx_memcpy(++last, r->args.data, r->args.len); |
93a0d80fdce6
add args in redirect to a directory
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
171 } |
93a0d80fdce6
add args in redirect to a directory
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
172 } |
557 | 173 |
509 | 174 /* |
175 * we do not need to set the r->headers_out.location->hash and | |
176 * r->headers_out.location->key fields | |
177 */ | |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
178 |
2038
93a0d80fdce6
add args in redirect to a directory
Igor Sysoev <igor@sysoev.ru>
parents:
1799
diff
changeset
|
179 r->headers_out.location->value.len = len; |
557 | 180 r->headers_out.location->value.data = location; |
287
35a6a9df2d25
nginx-0.0.2-2004-03-12-19:57:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
181 |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
182 return NGX_HTTP_MOVED_PERMANENTLY; |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
183 } |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
184 |
461 | 185 #if !(NGX_WIN32) /* the not regular files are probably Unix specific */ |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
170
diff
changeset
|
186 |
1454 | 187 if (!of.is_file) { |
3498
9f20a6e758c3
do not log misleading errno in "not a regular file" error
Igor Sysoev <igor@sysoev.ru>
parents:
3178
diff
changeset
|
188 ngx_log_error(NGX_LOG_CRIT, log, 0, |
557 | 189 "\"%s\" is not a regular file", path.data); |
176
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
170
diff
changeset
|
190 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
170
diff
changeset
|
191 return NGX_HTTP_NOT_FOUND; |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
170
diff
changeset
|
192 } |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
170
diff
changeset
|
193 |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
170
diff
changeset
|
194 #endif |
c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
Igor Sysoev <igor@sysoev.ru>
parents:
170
diff
changeset
|
195 |
2182
23309bcd9937
allow file existence test for POST requests in static module
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
196 if (r->method & NGX_HTTP_POST) { |
23309bcd9937
allow file existence test for POST requests in static module
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
197 return NGX_HTTP_NOT_ALLOWED; |
23309bcd9937
allow file existence test for POST requests in static module
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
198 } |
23309bcd9937
allow file existence test for POST requests in static module
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
199 |
23309bcd9937
allow file existence test for POST requests in static module
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
200 rc = ngx_http_discard_request_body(r); |
23309bcd9937
allow file existence test for POST requests in static module
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
201 |
23309bcd9937
allow file existence test for POST requests in static module
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
202 if (rc != NGX_OK) { |
23309bcd9937
allow file existence test for POST requests in static module
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
203 return rc; |
23309bcd9937
allow file existence test for POST requests in static module
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
204 } |
23309bcd9937
allow file existence test for POST requests in static module
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
205 |
509 | 206 log->action = "sending response to client"; |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
207 |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
208 r->headers_out.status = NGX_HTTP_OK; |
1454 | 209 r->headers_out.content_length_n = of.size; |
210 r->headers_out.last_modified_time = of.mtime; | |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
211 |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
212 if (ngx_http_set_content_type(r) != NGX_OK) { |
200
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
199
diff
changeset
|
213 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
199
diff
changeset
|
214 } |
abeaebe0a33c
nginx-0.0.1-2003-11-28-20:41:47 import
Igor Sysoev <igor@sysoev.ru>
parents:
199
diff
changeset
|
215 |
2403
5e5caa72f61e
fix zero length static response, the bug was introduced in r2378
Igor Sysoev <igor@sysoev.ru>
parents:
2377
diff
changeset
|
216 if (r != r->main && of.size == 0) { |
583 | 217 return ngx_http_send_header(r); |
218 } | |
219 | |
587 | 220 r->allow_ranges = 1; |
221 | |
577 | 222 /* we need to allocate all before the header would be sent */ |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
223 |
577 | 224 b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t)); |
225 if (b == NULL) { | |
226 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
227 } | |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
228 |
577 | 229 b->file = ngx_pcalloc(r->pool, sizeof(ngx_file_t)); |
230 if (b->file == NULL) { | |
231 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
232 } | |
403
ea3113b181d1
nginx-0.0.9-2004-07-28-23:21:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
400
diff
changeset
|
233 |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
234 rc = ngx_http_send_header(r); |
143
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
235 |
585 | 236 if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) { |
143
5526213be452
nginx-0.0.1-2003-10-10-19:10:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
142
diff
changeset
|
237 return rc; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
96
diff
changeset
|
238 } |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
89
diff
changeset
|
239 |
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:
334
diff
changeset
|
240 b->file_pos = 0; |
1454 | 241 b->file_last = of.size; |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
242 |
577 | 243 b->in_file = b->file_last ? 1: 0; |
597 | 244 b->last_buf = (r == r->main) ? 1: 0; |
577 | 245 b->last_in_chain = 1; |
246 | |
1696 | 247 b->file->fd = of.fd; |
557 | 248 b->file->name = path; |
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:
334
diff
changeset
|
249 b->file->log = log; |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2182
diff
changeset
|
250 b->file->directio = of.is_directio; |
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:
334
diff
changeset
|
251 |
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:
334
diff
changeset
|
252 out.buf = b; |
153
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
148
diff
changeset
|
253 out.next = NULL; |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
148
diff
changeset
|
254 |
c71aeb75c071
nginx-0.0.1-2003-10-21-20:49:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
148
diff
changeset
|
255 return ngx_http_output_filter(r, &out); |
1
d220029ac7f3
nginx-0.0.1-2002-08-15-21:20:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
256 } |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
257 |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
258 |
509 | 259 static ngx_int_t |
681 | 260 ngx_http_static_init(ngx_conf_t *cf) |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
261 { |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
262 ngx_http_handler_pt *h; |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
263 ngx_http_core_main_conf_t *cmcf; |
396
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
346
diff
changeset
|
264 |
681 | 265 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); |
577 | 266 |
501 | 267 h = ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers); |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
268 if (h == NULL) { |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
269 return NGX_ERROR; |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
270 } |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
271 |
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
200
diff
changeset
|
272 *h = ngx_http_static_handler; |
148
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
273 |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
274 return NGX_OK; |
5afee0074707
nginx-0.0.1-2003-10-17-00:19:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
143
diff
changeset
|
275 } |