Mercurial > hg > nginx
comparison src/http/modules/ngx_http_static_handler.c @ 170:c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 02 Nov 2003 22:56:18 +0000 |
parents | 894a01c6aea3 |
children | c0552e5ab567 |
comparison
equal
deleted
inserted
replaced
169:edf29bb717da | 170:c42be4185301 |
---|---|
37 }; | 37 }; |
38 | 38 |
39 | 39 |
40 int ngx_http_static_translate_handler(ngx_http_request_t *r) | 40 int ngx_http_static_translate_handler(ngx_http_request_t *r) |
41 { | 41 { |
42 int rc, level; | |
42 char *location, *last; | 43 char *location, *last; |
43 ngx_err_t err; | 44 ngx_err_t err; |
44 ngx_http_core_loc_conf_t *clcf; | 45 ngx_http_core_loc_conf_t *clcf; |
45 | 46 |
46 if (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) { | 47 if (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) { |
114 NGX_FILE_RDONLY, NGX_FILE_OPEN); | 115 NGX_FILE_RDONLY, NGX_FILE_OPEN); |
115 } | 116 } |
116 | 117 |
117 if (r->file.fd == NGX_INVALID_FILE) { | 118 if (r->file.fd == NGX_INVALID_FILE) { |
118 err = ngx_errno; | 119 err = ngx_errno; |
119 ngx_log_error(NGX_LOG_ERR, r->connection->log, ngx_errno, | 120 |
121 if (err == NGX_ENOENT || err == NGX_ENOTDIR) { | |
122 level = NGX_LOG_ERR; | |
123 rc = NGX_HTTP_NOT_FOUND; | |
124 | |
125 } else if (err == NGX_EACCES) { | |
126 level = NGX_LOG_ERR; | |
127 rc = NGX_HTTP_FORBIDDEN; | |
128 | |
129 } else { | |
130 level = NGX_LOG_CRIT; | |
131 rc = NGX_HTTP_INTERNAL_SERVER_ERROR; | |
132 } | |
133 | |
134 ngx_log_error(level, r->connection->log, ngx_errno, | |
120 ngx_open_file_n " \"%s\" failed", r->file.name.data); | 135 ngx_open_file_n " \"%s\" failed", r->file.name.data); |
121 | 136 |
122 if (err == NGX_ENOENT || err == NGX_ENOTDIR) { | 137 return rc; |
123 return NGX_HTTP_NOT_FOUND; | |
124 | |
125 } else if (err == NGX_EACCES) { | |
126 return NGX_HTTP_FORBIDDEN; | |
127 | |
128 } else { | |
129 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
130 } | |
131 } | 138 } |
132 | 139 |
133 ngx_log_debug(r->connection->log, "FILE: %d" _ r->file.fd); | 140 ngx_log_debug(r->connection->log, "FILE: %d" _ r->file.fd); |
134 | 141 |
135 if (!r->file.info_valid) { | 142 if (!r->file.info_valid) { |