Mercurial > hg > nginx-ranges
comparison src/http/ngx_http_header_filter.c @ 48:6cfc63e68377 NGINX_0_1_24
nginx 0.1.24
*) Feature: the ngx_http_ssi_filter_module supports the QUERY_STRING
and DOCUMENT_URI variables.
*) Bugfix: the ngx_http_autoindex_module may some times return the 404
response for existent directory, if this directory was used in
"alias" directive.
*) Bugfix: the ngx_http_ssi_filter_module ran incorrectly for large
responses.
*) Bugfix: the lack of the "Referer" header line was always accounted
as valid referrer.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Fri, 04 Mar 2005 00:00:00 +0300 |
parents | 41ccba1aba45 |
children |
comparison
equal
deleted
inserted
replaced
47:4ae32548452c | 48:6cfc63e68377 |
---|---|
32 NGX_MODULE, | 32 NGX_MODULE, |
33 &ngx_http_header_filter_module_ctx, /* module context */ | 33 &ngx_http_header_filter_module_ctx, /* module context */ |
34 NULL, /* module directives */ | 34 NULL, /* module directives */ |
35 NGX_HTTP_MODULE, /* module type */ | 35 NGX_HTTP_MODULE, /* module type */ |
36 ngx_http_header_filter_init, /* init module */ | 36 ngx_http_header_filter_init, /* init module */ |
37 NULL /* init child */ | 37 NULL /* init process */ |
38 }; | 38 }; |
39 | 39 |
40 | 40 |
41 static char server_string[] = "Server: " NGINX_VER CRLF; | 41 static char server_string[] = "Server: " NGINX_VER CRLF; |
42 | 42 |
48 ngx_null_string, /* "202 Accepted" */ | 48 ngx_null_string, /* "202 Accepted" */ |
49 ngx_null_string, /* "203 Non-Authoritative Information" */ | 49 ngx_null_string, /* "203 Non-Authoritative Information" */ |
50 ngx_null_string, /* "204 No Content" */ | 50 ngx_null_string, /* "204 No Content" */ |
51 ngx_null_string, /* "205 Reset Content" */ | 51 ngx_null_string, /* "205 Reset Content" */ |
52 ngx_string("206 Partial Content"), | 52 ngx_string("206 Partial Content"), |
53 ngx_null_string, /* "207 Multi-Status" */ | 53 |
54 | 54 /* ngx_null_string, */ /* "207 Multi-Status" */ |
55 #if 0 | 55 |
56 ngx_null_string, /* "300 Multiple Choices" */ | 56 #define NGX_HTTP_LEVEL_200 7 |
57 #endif | 57 |
58 /* ngx_null_string, */ /* "300 Multiple Choices" */ | |
58 | 59 |
59 ngx_string("301 Moved Permanently"), | 60 ngx_string("301 Moved Permanently"), |
60 #if 0 | |
61 ngx_string("302 Moved Temporarily"), | 61 ngx_string("302 Moved Temporarily"), |
62 #else | |
63 ngx_string("302 Found"), | |
64 #endif | |
65 ngx_null_string, /* "303 See Other" */ | 62 ngx_null_string, /* "303 See Other" */ |
66 ngx_string("304 Not Modified"), | 63 ngx_string("304 Not Modified"), |
67 | 64 |
65 /* ngx_null_string, */ /* "305 Use Proxy" */ | |
66 /* ngx_null_string, */ /* "306 unused" */ | |
67 /* ngx_null_string, */ /* "307 Temporary Redirect" */ | |
68 | |
69 #define NGX_HTTP_LEVEL_300 4 | |
70 | |
68 ngx_string("400 Bad Request"), | 71 ngx_string("400 Bad Request"), |
69 ngx_string("401 Unauthorized"), | 72 ngx_string("401 Unauthorized"), |
70 ngx_null_string, /* "402 Payment Required" */ | 73 ngx_string("402 Payment Required"), |
71 ngx_string("403 Forbidden"), | 74 ngx_string("403 Forbidden"), |
72 ngx_string("404 Not Found"), | 75 ngx_string("404 Not Found"), |
73 ngx_string("405 Not Allowed"), | 76 ngx_string("405 Not Allowed"), |
74 ngx_null_string, /* "406 Not Acceptable" */ | 77 ngx_string("406 Not Acceptable"), |
75 ngx_null_string, /* "407 Proxy Authentication Required" */ | 78 ngx_null_string, /* "407 Proxy Authentication Required" */ |
76 ngx_string("408 Request Time-out"), | 79 ngx_string("408 Request Time-out"), |
77 ngx_null_string, /* "409 Conflict" */ | 80 ngx_null_string, /* "409 Conflict" */ |
78 ngx_null_string, /* "410 Gone" */ | 81 ngx_string("410 Gone"), |
79 ngx_string("411 Length Required"), | 82 ngx_string("411 Length Required"), |
80 ngx_null_string, /* "412 Precondition Failed" */ | 83 ngx_null_string, /* "412 Precondition Failed" */ |
81 ngx_string("413 Request Entity Too Large"), | 84 ngx_string("413 Request Entity Too Large"), |
82 ngx_null_string, /* "414 Request-URI Too Large" but we never send it | 85 ngx_null_string, /* "414 Request-URI Too Large", but we never send it |
83 * because we treat such requests as the HTTP/0.9 | 86 * because we treat such requests as the HTTP/0.9 |
84 * requests and send only a body without a header | 87 * requests and send only a body without a header |
85 */ | 88 */ |
86 ngx_null_string, /* "415 Unsupported Media Type" */ | 89 ngx_null_string, /* "415 Unsupported Media Type" */ |
87 ngx_string("416 Requested Range Not Satisfiable"), | 90 ngx_string("416 Requested Range Not Satisfiable"), |
88 | 91 |
92 /* ngx_null_string, */ /* "417 Expectation Failed" */ | |
93 /* ngx_null_string, */ /* "418 unused" */ | |
94 /* ngx_null_string, */ /* "419 unused" */ | |
95 /* ngx_null_string, */ /* "420 unused" */ | |
96 /* ngx_null_string, */ /* "421 unused" */ | |
97 /* ngx_null_string, */ /* "422 Unprocessable Entity" */ | |
98 /* ngx_null_string, */ /* "423 Locked" */ | |
99 /* ngx_null_string, */ /* "424 Failed Dependency" */ | |
100 | |
101 #define NGX_HTTP_LEVEL_400 17 | |
102 | |
89 ngx_string("500 Internal Server Error"), | 103 ngx_string("500 Internal Server Error"), |
90 ngx_string("501 Method Not Implemented"), | 104 ngx_string("501 Method Not Implemented"), |
91 ngx_string("502 Bad Gateway"), | 105 ngx_string("502 Bad Gateway"), |
92 ngx_string("503 Service Temporarily Unavailable"), | 106 ngx_string("503 Service Temporarily Unavailable"), |
93 ngx_string("504 Gateway Time-out") | 107 ngx_string("504 Gateway Time-out") |
108 | |
109 /* ngx_null_string, */ /* "505 HTTP Version Not Supported" */ | |
110 /* ngx_null_string, */ /* "506 Variant Also Negotiates" */ | |
111 /* ngx_null_string, */ /* "507 Insufficient Storage" */ | |
112 /* ngx_null_string, */ /* "508 unused" */ | |
113 /* ngx_null_string, */ /* "509 unused" */ | |
114 /* ngx_null_string, */ /* "510 Not Extended" */ | |
94 }; | 115 }; |
95 | 116 |
96 | 117 |
97 ngx_http_header_t ngx_http_headers_out[] = { | 118 ngx_http_header_t ngx_http_headers_out[] = { |
98 { ngx_string("Server"), offsetof(ngx_http_headers_out_t, server) }, | 119 { ngx_string("Server"), offsetof(ngx_http_headers_out_t, server) }, |
99 { ngx_string("Date"), offsetof(ngx_http_headers_out_t, date) }, | 120 { ngx_string("Date"), offsetof(ngx_http_headers_out_t, date) }, |
100 { ngx_string("Content-Type"), | 121 { ngx_string("Content-Type"), |
101 offsetof(ngx_http_headers_out_t, content_type) }, | 122 offsetof(ngx_http_headers_out_t, content_type) }, |
102 { ngx_string("Content-Length"), | 123 { ngx_string("Content-Length"), |
103 offsetof(ngx_http_headers_out_t, content_length) }, | 124 offsetof(ngx_http_headers_out_t, content_length) }, |
104 { ngx_string("Content-Encoding"), | 125 { ngx_string("Content-Encoding"), |
105 offsetof(ngx_http_headers_out_t, content_encoding) }, | 126 offsetof(ngx_http_headers_out_t, content_encoding) }, |
106 { ngx_string("Location"), offsetof(ngx_http_headers_out_t, location) }, | 127 { ngx_string("Location"), offsetof(ngx_http_headers_out_t, location) }, |
107 { ngx_string("Last-Modified"), | 128 { ngx_string("Last-Modified"), |
108 offsetof(ngx_http_headers_out_t, last_modified) }, | 129 offsetof(ngx_http_headers_out_t, last_modified) }, |
109 { ngx_string("Accept-Ranges"), | 130 { ngx_string("Accept-Ranges"), |
110 offsetof(ngx_http_headers_out_t, accept_ranges) }, | 131 offsetof(ngx_http_headers_out_t, accept_ranges) }, |
111 { ngx_string("Expires"), offsetof(ngx_http_headers_out_t, expires) }, | 132 { ngx_string("Expires"), offsetof(ngx_http_headers_out_t, expires) }, |
112 { ngx_string("Cache-Control"), | 133 { ngx_string("Cache-Control"), |
113 offsetof(ngx_http_headers_out_t, cache_control) }, | 134 offsetof(ngx_http_headers_out_t, cache_control) }, |
114 { ngx_string("ETag"), offsetof(ngx_http_headers_out_t, etag) }, | 135 { ngx_string("ETag"), offsetof(ngx_http_headers_out_t, etag) }, |
115 | 136 |
116 { ngx_null_string, 0 } | 137 { ngx_null_string, 0 } |
117 }; | 138 }; |
118 | 139 |
165 /* 2XX */ | 186 /* 2XX */ |
166 status = r->headers_out.status - NGX_HTTP_OK; | 187 status = r->headers_out.status - NGX_HTTP_OK; |
167 | 188 |
168 } else if (r->headers_out.status < NGX_HTTP_BAD_REQUEST) { | 189 } else if (r->headers_out.status < NGX_HTTP_BAD_REQUEST) { |
169 /* 3XX */ | 190 /* 3XX */ |
170 status = r->headers_out.status - NGX_HTTP_MOVED_PERMANENTLY + 8; | 191 status = r->headers_out.status - NGX_HTTP_MOVED_PERMANENTLY |
192 + NGX_HTTP_LEVEL_200; | |
171 | 193 |
172 if (r->headers_out.status == NGX_HTTP_NOT_MODIFIED) { | 194 if (r->headers_out.status == NGX_HTTP_NOT_MODIFIED) { |
173 r->header_only = 1; | 195 r->header_only = 1; |
174 } | 196 } |
175 | 197 |
176 } else if (r->headers_out.status < NGX_HTTP_INTERNAL_SERVER_ERROR) { | 198 } else if (r->headers_out.status < NGX_HTTP_INTERNAL_SERVER_ERROR) { |
177 /* 4XX */ | 199 /* 4XX */ |
178 status = r->headers_out.status - NGX_HTTP_BAD_REQUEST + 8 + 4; | 200 status = r->headers_out.status - NGX_HTTP_BAD_REQUEST |
201 + NGX_HTTP_LEVEL_200 | |
202 + NGX_HTTP_LEVEL_300; | |
179 | 203 |
180 } else { | 204 } else { |
181 /* 5XX */ | 205 /* 5XX */ |
182 status = r->headers_out.status | 206 status = r->headers_out.status - NGX_HTTP_INTERNAL_SERVER_ERROR |
183 - NGX_HTTP_INTERNAL_SERVER_ERROR + 8 + 4 + 17; | 207 + NGX_HTTP_LEVEL_200 |
208 + NGX_HTTP_LEVEL_300 | |
209 + NGX_HTTP_LEVEL_400; | |
184 } | 210 } |
185 | 211 |
186 len += http_codes[status].len; | 212 len += http_codes[status].len; |
187 } | 213 } |
188 | 214 |