comparison src/http/ngx_http_request.c @ 201:267ea1d98683

nginx-0.0.1-2003-11-30-23:03:18 import
author Igor Sysoev <igor@sysoev.ru>
date Sun, 30 Nov 2003 20:03:18 +0000
parents abeaebe0a33c
children e1c815be05ae
comparison
equal deleted inserted replaced
200:abeaebe0a33c 201:267ea1d98683
357 } 357 }
358 358
359 if (r->complex_uri) { 359 if (r->complex_uri) {
360 rc = ngx_http_parse_complex_uri(r); 360 rc = ngx_http_parse_complex_uri(r);
361 361
362 if (rc == NGX_HTTP_INTERNAL_SERVER_ERROR) {
363 ngx_http_close_request(r, rc);
364 ngx_http_close_connection(c);
365 return;
366 }
367
368 if (rc != NGX_OK) {
369 r->request_line.len = r->request_end - r->request_start;
370 r->request_line.data = r->request_start;
371 r->request_line.data[r->request_line.len] = '\0';
372
373 ngx_http_client_error(r, rc, NGX_HTTP_BAD_REQUEST);
374 return;
375 }
376
362 } else { 377 } else {
363 ngx_cpystrn(r->uri.data, r->uri_start, r->uri.len + 1); 378 ngx_cpystrn(r->uri.data, r->uri_start, r->uri.len + 1);
364 } 379 }
365 380
366 381
384 r->request_line.len + 1); 399 r->request_line.len + 1);
385 400
386 } else { 401 } else {
387 r->request_line.data = r->request_start; 402 r->request_line.data = r->request_start;
388 r->request_line.data[r->request_line.len] = '\0'; 403 r->request_line.data[r->request_line.len] = '\0';
389 }
390
391
392 if (rc != NGX_OK) {
393 /*
394 * we check ngx_http_parse_complex_uri() result here to log
395 * the request line
396 */
397 ngx_http_client_error(r, rc, NGX_HTTP_BAD_REQUEST);
398 return;
399 } 404 }
400 405
401 406
402 if (r->uri_ext) { 407 if (r->uri_ext) {
403 408
534 ngx_http_core_srv_conf_t *cscf; 539 ngx_http_core_srv_conf_t *cscf;
535 540
536 c = rev->data; 541 c = rev->data;
537 r = c->data; 542 r = c->data;
538 543
539 ngx_log_debug(rev->log, "http process request header line"); 544 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0,
545 "http process request header line");
540 546
541 if (rev->timedout) { 547 if (rev->timedout) {
542 ngx_http_client_error(r, 0, NGX_HTTP_REQUEST_TIME_OUT); 548 ngx_http_client_error(r, 0, NGX_HTTP_REQUEST_TIME_OUT);
543 return; 549 return;
544 } 550 }
1385 1391
1386 1392
1387 void ngx_http_close_request(ngx_http_request_t *r, int error) 1393 void ngx_http_close_request(ngx_http_request_t *r, int error)
1388 { 1394 {
1389 ngx_int_t i; 1395 ngx_int_t i;
1396 ngx_log_t *log;
1390 ngx_http_log_ctx_t *ctx; 1397 ngx_http_log_ctx_t *ctx;
1391 ngx_http_cleanup_t *cleanup; 1398 ngx_http_cleanup_t *cleanup;
1392 1399
1393 ngx_log_debug(r->connection->log, "close http request"); 1400 log = r->connection->log;
1401
1402 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, log, 0, "http close request");
1394 1403
1395 if (r->pool == NULL) { 1404 if (r->pool == NULL) {
1396 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, 1405 ngx_log_error(NGX_LOG_ALERT, log, 0,
1397 "http request already closed"); 1406 "http request already closed");
1398 return; 1407 return;
1399 } 1408 }
1400 1409
1401 if (error) { 1410 if (error) {
1404 1413
1405 ngx_http_log_handler(r); 1414 ngx_http_log_handler(r);
1406 1415
1407 cleanup = r->cleanup.elts; 1416 cleanup = r->cleanup.elts;
1408 for (i = 0; i < r->cleanup.nelts; i++) { 1417 for (i = 0; i < r->cleanup.nelts; i++) {
1418 if (!cleanup[i].valid) {
1419 continue;
1420 }
1421
1409 if (cleanup[i].cache) { 1422 if (cleanup[i].cache) {
1410 ngx_http_cache_unlock(cleanup[i].data.cache.hash, 1423 ngx_http_cache_unlock(cleanup[i].data.cache.hash,
1411 cleanup[i].data.cache.cache, 1424 cleanup[i].data.cache.cache, log);
1412 r->connection->log);
1413 continue; 1425 continue;
1414 } 1426 }
1415 1427
1428 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, "http cleanup fd: %d",
1429 cleanup[i].data.file.fd);
1430
1416 if (ngx_close_file(cleanup[i].data.file.fd) == NGX_FILE_ERROR) { 1431 if (ngx_close_file(cleanup[i].data.file.fd) == NGX_FILE_ERROR) {
1417 ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno, 1432 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
1418 ngx_close_file_n " \"%s\" failed", 1433 ngx_close_file_n " \"%s\" failed",
1419 cleanup[i].data.file.name); 1434 cleanup[i].data.file.name);
1420 } 1435 }
1421 } 1436 }
1422 1437
1438 /* STUB */
1423 if (r->file.fd != NGX_INVALID_FILE) { 1439 if (r->file.fd != NGX_INVALID_FILE) {
1424 if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR) { 1440 if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR) {
1425 ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno, 1441 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
1426 ngx_close_file_n " \"%s\" failed", r->file.name.data); 1442 ngx_close_file_n " \"%s\" failed", r->file.name.data);
1427 } 1443 }
1428 } 1444 }
1429 1445
1430 /* ctx->url was allocated from r->pool */ 1446 /* ctx->url was allocated from r->pool */
1431 ctx = r->connection->log->data; 1447 ctx = log->data;
1432 ctx->url = NULL; 1448 ctx->url = NULL;
1433 1449
1434 ngx_destroy_pool(r->pool); 1450 ngx_destroy_pool(r->pool);
1435 1451
1436 return; 1452 return;