Mercurial > hg > nginx
comparison src/http/ngx_http_event.c @ 2:ffffe1499bce
nginx-0.0.1-2002-08-16-19:27:03 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 16 Aug 2002 15:27:03 +0000 |
parents | d220029ac7f3 |
children | 34a521b1a148 |
comparison
equal
deleted
inserted
replaced
1:d220029ac7f3 | 2:ffffe1499bce |
---|---|
178 return ngx_process_http_request(r); | 178 return ngx_process_http_request(r); |
179 } | 179 } |
180 | 180 |
181 static int ngx_process_http_request(ngx_http_request_t *r) | 181 static int ngx_process_http_request(ngx_http_request_t *r) |
182 { | 182 { |
183 int err; | |
184 char *name, *loc, *file; | |
185 | |
186 ngx_log_debug(r->connection->log, "HTTP request"); | |
187 | |
188 if (*(r->uri_end - 1) == '/') { | |
189 r->handler = NGX_HTTP_DIRECTORY_HANDLER; | |
190 return NGX_OK; | |
191 } | |
192 | |
193 /* 20 bytes is spare space for some index name, i.e. index.html */ | |
194 r->filename_len = r->uri_end - r->uri_start + r->server->doc_root_len + 20; | |
195 | |
196 ngx_test_null(r->filename, | |
197 ngx_palloc(r->pool, r->filename_len), | |
198 ngx_http_error(r, NGX_HTTP_INTERNAL_SERVER_ERROR)); | |
199 | |
200 r->location = ngx_cpystrn(r->filename, r->server->doc_root, | |
201 r->server->doc_root_len); | |
202 file = ngx_cpystrn(r->location, r->uri_start, | |
203 r->uri_end - r->uri_start + 1); | |
204 | |
205 ngx_log_debug(r->connection->log, "HTTP filename: '%s'" _ r->filename); | |
206 | |
207 } | |
208 #if 0 | |
209 | |
210 if (ngx_stat(r->filename, &r->stat) == -1) { | |
211 err = ngx_errno; | |
212 ngx_log_error(GX_LOG_ERR, r->connection->log, err, | |
213 "ngx_process_http_request: " | |
214 ngx_stat_n " %s failed", r->filename); | |
215 | |
216 if (err == NGX_ENOENT) | |
217 return ngx_http_error(r, NGX_HTTP_NOT_FOUND); | |
218 else | |
219 return ngx_http_error(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | |
220 } | |
221 | |
222 if (ngx_is_dir(r->stat)) { | |
223 *file++ = '/'; | |
224 *file = '\0'; | |
225 r->headers_out->location = r->location; | |
226 return ngx_http_redirect(r, NGX_HTTP_MOVED_PERMANENTLY); | |
227 } | |
228 | |
229 r->stat_valid = 1; | |
230 r->handler = NGX_HTTP_STATIC_HANDLER; | |
231 return NGX_OK; | |
232 } | |
233 | |
234 static int ngx_http_handler(ngx_http_request_t *r, int handler) | |
235 { | |
236 if (handler == NGX_HTTP_STATIC_HANDLER) | |
237 return ngx_http_static_handler(r); | |
238 | |
239 elsif (handler == NGX_HTTP_DIRECTORY_HANDLER) | |
240 return ngx_http_index_handler(r); | |
241 | |
242 return ngx_http_error(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | |
243 } | |
244 #endif | |
245 | |
246 static int ngx_http_redirect(ngx_http_request_t *r, int redirect) | |
247 { | |
248 /* STUB */ | |
249 return -1; | |
250 } | |
251 | |
252 static int ngx_http_error(ngx_http_request_t *r, int error) | |
253 { | |
254 /* STUB */ | |
183 return -1; | 255 return -1; |
184 } | 256 } |
185 | 257 |
186 #if 0 | 258 #if 0 |
187 | 259 |