comparison src/http/ngx_http_core_module.c @ 74:17ab1af8c3dd

nginx-0.0.1-2003-04-11-20:01:14 import
author Igor Sysoev <igor@sysoev.ru>
date Fri, 11 Apr 2003 16:01:14 +0000
parents 59229033ae93
children 869b10be682f
comparison
equal deleted inserted replaced
73:4534060fde92 74:17ab1af8c3dd
368 r->file.info.dwFileAttributes = GetFileAttributes(r->file.name.data); 368 r->file.info.dwFileAttributes = GetFileAttributes(r->file.name.data);
369 if (r->file.info.dwFileAttributes == INVALID_FILE_ATTRIBUTES) { 369 if (r->file.info.dwFileAttributes == INVALID_FILE_ATTRIBUTES) {
370 err = ngx_errno; 370 err = ngx_errno;
371 ngx_log_error(NGX_LOG_ERR, r->connection->log, err, 371 ngx_log_error(NGX_LOG_ERR, r->connection->log, err,
372 "ngx_http_core_translate_handler: " 372 "ngx_http_core_translate_handler: "
373 ngx_file_type_n " %s failed", r->file.name.data); 373 ngx_file_type_n " \"%s\" failed", r->file.name.data);
374 374
375 if (err == NGX_ENOENT) { 375 if (err == NGX_ENOENT) {
376 return NGX_HTTP_NOT_FOUND; 376 return NGX_HTTP_NOT_FOUND;
377 377
378 } else if (err == ERROR_PATH_NOT_FOUND) { 378 } else if (err == NGX_ENOTDIR) {
379 return NGX_HTTP_NOT_FOUND; 379 return NGX_HTTP_NOT_FOUND;
380 380
381 } else if (err == NGX_EACCES) { 381 } else if (err == NGX_EACCES) {
382 return NGX_HTTP_FORBIDDEN; 382 return NGX_HTTP_FORBIDDEN;
383 383
394 394
395 if (r->file.fd == NGX_INVALID_FILE) { 395 if (r->file.fd == NGX_INVALID_FILE) {
396 err = ngx_errno; 396 err = ngx_errno;
397 ngx_log_error(NGX_LOG_ERR, r->connection->log, ngx_errno, 397 ngx_log_error(NGX_LOG_ERR, r->connection->log, ngx_errno,
398 "ngx_http_core_handler: " 398 "ngx_http_core_handler: "
399 ngx_open_file_n " %s failed", r->file.name.data); 399 ngx_open_file_n " \"%s\" failed", r->file.name.data);
400 400
401 if (err == NGX_ENOENT) { 401 if (err == NGX_ENOENT) {
402 return NGX_HTTP_NOT_FOUND; 402 return NGX_HTTP_NOT_FOUND;
403 #if (WIN32) 403
404 } else if (err == ERROR_PATH_NOT_FOUND) {
405 return NGX_HTTP_NOT_FOUND;
406 #else
407 } else if (err == NGX_ENOTDIR) { 404 } else if (err == NGX_ENOTDIR) {
408 return NGX_HTTP_NOT_FOUND; 405 return NGX_HTTP_NOT_FOUND;
409 #endif 406
410 } else if (err == NGX_EACCES) { 407 } else if (err == NGX_EACCES) {
411 return NGX_HTTP_FORBIDDEN; 408 return NGX_HTTP_FORBIDDEN;
412 409
413 } else { 410 } else {
414 return NGX_HTTP_INTERNAL_SERVER_ERROR; 411 return NGX_HTTP_INTERNAL_SERVER_ERROR;
417 414
418 if (!r->file.info_valid) { 415 if (!r->file.info_valid) {
419 if (ngx_stat_fd(r->file.fd, &r->file.info) == NGX_FILE_ERROR) { 416 if (ngx_stat_fd(r->file.fd, &r->file.info) == NGX_FILE_ERROR) {
420 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno, 417 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
421 "ngx_http_core_handler: " 418 "ngx_http_core_handler: "
422 ngx_stat_fd_n " %s failed", r->file.name.data); 419 ngx_stat_fd_n " \"%s\" failed", r->file.name.data);
423 420
424 if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR) { 421 if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR) {
425 ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno, 422 ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno,
426 "ngx_http_core_handler: " 423 "ngx_http_core_handler: "
427 ngx_close_file_n " %s failed", r->file.name.data); 424 ngx_close_file_n " \"%s\" failed",
425 r->file.name.data);
428 } 426 }
429 427
430 return NGX_HTTP_INTERNAL_SERVER_ERROR; 428 return NGX_HTTP_INTERNAL_SERVER_ERROR;
431 } 429 }
432 430
439 437
440 #if !(WIN9X) 438 #if !(WIN9X)
441 if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR) { 439 if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR) {
442 ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno, 440 ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno,
443 "ngx_http_core_handler: " 441 "ngx_http_core_handler: "
444 ngx_close_file_n " %s failed", r->file.name.data); 442 ngx_close_file_n " \"%s\" failed", r->file.name.data);
445 } 443 }
446 #endif 444 #endif
447 445
448 /* BROKEN: need to include server name */ 446 /* BROKEN: need to include server name */
449 447
485 483
486 if (rc != NGX_DECLINED) { 484 if (rc != NGX_DECLINED) {
487 485
488 if (rc == NGX_HTTP_NOT_FOUND) { 486 if (rc == NGX_HTTP_NOT_FOUND) {
489 ngx_log_error(NGX_LOG_ERR, r->connection->log, r->path_err, 487 ngx_log_error(NGX_LOG_ERR, r->connection->log, r->path_err,
490 "%s is not found", r->path.data); 488 "\"%s\" is not found", r->path.data);
491 } 489 }
492 490
493 if (rc == NGX_HTTP_FORBIDDEN) { 491 if (rc == NGX_HTTP_FORBIDDEN) {
494 ngx_log_error(NGX_LOG_ERR, r->connection->log, r->path_err, 492 ngx_log_error(NGX_LOG_ERR, r->connection->log, r->path_err,
495 "%s is forbidden", r->path.data); 493 "\"%s\" is forbidden", r->path.data);
496 } 494 }
497 495
498 return rc; 496 return rc;
499 } 497 }
500 } 498 }
501 499
502 r->path.data[r->path.len] = '\0'; 500 r->path.data[r->path.len] = '\0';
503 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, 501 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
504 "directory index of %s is forbidden", r->path.data); 502 "directory index of \"%s\" is forbidden", r->path.data);
505 503
506 return NGX_HTTP_FORBIDDEN; 504 return NGX_HTTP_FORBIDDEN;
507 } 505 }
508 506
509 507
548 ngx_http_log_handler(r); 546 ngx_http_log_handler(r);
549 547
550 if (r->file.fd != NGX_INVALID_FILE) { 548 if (r->file.fd != NGX_INVALID_FILE) {
551 if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR) { 549 if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR) {
552 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno, 550 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
553 ngx_close_file_n " failed"); 551 ngx_close_file_n " \"%s\" failed", r->file.name.data);
554 } 552 }
555 } 553 }
556 554
557 /* ctx->url was allocated from r->pool */ 555 /* ctx->url was allocated from r->pool */
558 ctx = (ngx_http_log_ctx_t *) c->log->data; 556 ctx = (ngx_http_log_ctx_t *) c->log->data;