comparison src/http/ngx_http_request.c @ 76:da9a3b14312d NGINX_0_1_38

nginx 0.1.38 *) Feature: the "limit_rate" directive is supported in in proxy and FastCGI mode. *) Feature: the "X-Accel-Limit-Rate" response header line is supported in proxy and FastCGI mode. *) Feature: the "break" directive. *) Feature: the "log_not_found" directive. *) Bugfix: the response status code was not changed when request was redirected by the ""X-Accel-Redirect" header line. *) Bugfix: the variables set by the "set" directive could not be used in SSI. *) Bugfix: the segmentation fault may occurred if the SSI page has more than one remote subrequest. *) Bugfix: nginx treated the backend response as invalid if the status line in the header was transferred in two packets; bug appeared in 0.1.29. *) Feature: the "ssi_types" directive. *) Feature: the "autoindex_exact_size" directive. *) Bugfix: the ngx_http_autoindex_module did not support the long file names in UTF-8. *) Feature: the IMAP/POP3 proxy.
author Igor Sysoev <http://sysoev.ru>
date Fri, 08 Jul 2005 00:00:00 +0400
parents 77969b24f355
children 6ae11d59d10e
comparison
equal deleted inserted replaced
75:985847bb65f9 76:da9a3b14312d
87 offsetof(ngx_http_headers_in_t, content_type), 87 offsetof(ngx_http_headers_in_t, content_type),
88 ngx_http_process_header_line }, 88 ngx_http_process_header_line },
89 89
90 { ngx_string("Range"), offsetof(ngx_http_headers_in_t, range), 90 { ngx_string("Range"), offsetof(ngx_http_headers_in_t, range),
91 ngx_http_process_header_line }, 91 ngx_http_process_header_line },
92
93 #if 0
94 { ngx_string("If-Range"), offsetof(ngx_http_headers_in_t, if_range),
95 ngx_http_process_header_line },
96 #endif
97 92
98 #if (NGX_HTTP_GZIP) 93 #if (NGX_HTTP_GZIP)
99 { ngx_string("Accept-Encoding"), 94 { ngx_string("Accept-Encoding"),
100 offsetof(ngx_http_headers_in_t, accept_encoding), 95 offsetof(ngx_http_headers_in_t, accept_encoding),
101 ngx_http_process_header_line }, 96 ngx_http_process_header_line },
1439 } 1434 }
1440 1435
1441 r->done = 1; 1436 r->done = 1;
1442 1437
1443 if (r != r->connection->data) { 1438 if (r != r->connection->data) {
1439 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1440 "http finalize non-active request: \"%V\"", &r->uri);
1444 return; 1441 return;
1445 } 1442 }
1446 1443
1447 if (r->parent) { 1444 if (r->parent) {
1448 1445
1449 pr = r->parent; 1446 pr = r->parent;
1447
1448 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1449 "http parent request: \"%V\"", &pr->uri);
1450 1450
1451 if (rc != NGX_AGAIN) { 1451 if (rc != NGX_AGAIN) {
1452 pr->connection->data = pr; 1452 pr->connection->data = pr;
1453 } 1453 }
1454 1454
1455 if (pr->postponed) { 1455 if (pr->postponed) {
1456
1457 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1458 "http request: \"%V\" has postponed", &pr->uri);
1456 1459
1457 if (rc != NGX_AGAIN && pr->postponed->request == r) { 1460 if (rc != NGX_AGAIN && pr->postponed->request == r) {
1458 pr->postponed = pr->postponed->next; 1461 pr->postponed = pr->postponed->next;
1459 1462
1460 if (pr->postponed == NULL) { 1463 if (pr->postponed == NULL) {
1461 return; 1464 return;
1462 } 1465 }
1463 } 1466 }
1464 1467
1468 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1469 "http request: \"%V\" still has postponed",
1470 &pr->uri);
1471
1465 if (pr->done) { 1472 if (pr->done) {
1466 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1473 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1467 "http wake request: \"%V\"", &pr->uri); 1474 "http wake parent request: \"%V\"", &pr->uri);
1468 1475
1469 pr->write_event_handler(pr); 1476 pr->write_event_handler(pr);
1470 } 1477 }
1471 } 1478 }
1472 1479
1481 1488
1482 if (r->connection->write->timer_set) { 1489 if (r->connection->write->timer_set) {
1483 ngx_del_timer(r->connection->write); 1490 ngx_del_timer(r->connection->write);
1484 } 1491 }
1485 1492
1486 if (rc == NGX_HTTP_CLIENT_CLOSED_REQUEST || r->closed) { 1493 if (r->connection->closed) {
1487 ngx_http_close_request(r, 0); 1494 ngx_http_close_request(r, 0);
1488 ngx_http_close_connection(r->connection); 1495 ngx_http_close_connection(r->connection);
1489 return; 1496 return;
1490 } 1497 }
1491 1498
1492 ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc)); 1499 ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc));
1493 1500
1494 return; 1501 return;
1495 1502 }
1496 } else if (rc == NGX_ERROR) { 1503
1504 if (rc == NGX_ERROR || r->connection->closed) {
1497 ngx_http_close_request(r, 0); 1505 ngx_http_close_request(r, 0);
1498 ngx_http_close_connection(r->connection); 1506 ngx_http_close_connection(r->connection);
1499 return; 1507 return;
1500 1508 }
1501 } else if (rc == NGX_AGAIN || r->out) { 1509
1510 if (rc == NGX_AGAIN || r->out) {
1502 (void) ngx_http_set_write_handler(r); 1511 (void) ngx_http_set_write_handler(r);
1503 return; 1512 return;
1504 } 1513 }
1505 1514
1506 if (r->connection->read->timer_set) { 1515 if (r->connection->read->timer_set) {
1550 ngx_http_core_loc_conf_t *clcf; 1559 ngx_http_core_loc_conf_t *clcf;
1551 1560
1552 r->http_state = NGX_HTTP_WRITING_REQUEST_STATE; 1561 r->http_state = NGX_HTTP_WRITING_REQUEST_STATE;
1553 1562
1554 r->write_event_handler = ngx_http_writer; 1563 r->write_event_handler = ngx_http_writer;
1564
1565 if (r->connection->closed) {
1566 return NGX_OK;
1567 }
1555 1568
1556 wev = r->connection->write; 1569 wev = r->connection->write;
1557 1570
1558 if (wev->ready && wev->delayed) { 1571 if (wev->ready && wev->delayed) {
1559 return NGX_OK; 1572 return NGX_OK;
1671 1684
1672 static ngx_int_t 1685 static ngx_int_t
1673 ngx_http_postponed_handler(ngx_http_request_t *r) 1686 ngx_http_postponed_handler(ngx_http_request_t *r)
1674 { 1687 {
1675 ngx_int_t rc; 1688 ngx_int_t rc;
1689 #if 0
1690 ngx_http_request_t *mr;
1691 #endif
1676 ngx_http_postponed_request_t *pr; 1692 ngx_http_postponed_request_t *pr;
1677 1693
1678 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1694 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1679 "http postpone handler \"%V\"", &r->uri); 1695 "http postpone handler \"%V\"", &r->uri);
1680 1696
1685 "http postponed data \"%V\" %p", &r->uri, pr->out); 1701 "http postponed data \"%V\" %p", &r->uri, pr->out);
1686 1702
1687 rc = ngx_http_output_filter(r, NULL); 1703 rc = ngx_http_output_filter(r, NULL);
1688 1704
1689 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1705 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1690 "http postponed output filter: %d", rc); 1706 "http postponed output filter: %d", rc);
1691 1707
1692 if (rc == NGX_AGAIN) { 1708 if (rc == NGX_AGAIN) {
1693 return rc; 1709 return rc;
1694 } 1710 }
1695 1711
1696 if (rc == NGX_ERROR) { 1712 /*
1697 /* NGX_ERROR may be returned by any filter */ 1713 * we treat NGX_ERROR as NGX_OK, because we need to complete
1698 r->connection->write->error = 1; 1714 * all postponed requests
1699 1715 */
1700 ngx_http_finalize_request(r, rc);
1701
1702 return NGX_DONE;
1703 }
1704 1716
1705 pr = r->postponed; 1717 pr = r->postponed;
1706 1718
1707 if (pr == NULL) { 1719 if (pr == NULL) {
1708 return NGX_OK; 1720 return NGX_OK;
1711 1723
1712 r = pr->request; 1724 r = pr->request;
1713 r->connection->data = r; 1725 r->connection->data = r;
1714 1726
1715 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1727 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1716 "http postponed request \"%V\"", &r->uri); 1728 "http wake child request \"%V\"", &r->uri);
1717 1729
1718 r->write_event_handler(r); 1730 r->write_event_handler(r);
1719 1731
1720 return NGX_DONE; 1732 return NGX_DONE;
1721 } 1733 }
1831 1843
1832 n = r->connection->recv(r->connection, buffer, size); 1844 n = r->connection->recv(r->connection, buffer, size);
1833 1845
1834 if (n == NGX_ERROR) { 1846 if (n == NGX_ERROR) {
1835 1847
1836 r->closed = 1; 1848 r->connection->closed = 1;
1837 1849
1838 /* 1850 /*
1839 * if a client request body is discarded then we already set 1851 * if a client request body is discarded then we already set
1840 * some HTTP response code for client and we can ignore the error 1852 * some HTTP response code for client and we can ignore the error
1841 */ 1853 */