Mercurial > hg > nginx-vendor-1-0
comparison src/http/ngx_http_core_module.c @ 580:4d3e880ce86c NGINX_0_8_42
nginx 0.8.42
*) Change: now nginx tests locations given by regular expressions, if
request was matched exactly by a location given by a prefix string.
The previous behavior has been introduced in 0.7.1.
*) Feature: the ngx_http_scgi_module.
Thanks to Manlio Perillo.
*) Feature: a text answer may be added to a "return" directive.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 21 Jun 2010 00:00:00 +0400 |
parents | bc110f60c0de |
children | c456a023113c |
comparison
equal
deleted
inserted
replaced
579:c570633043e7 | 580:4d3e880ce86c |
---|---|
863 { | 863 { |
864 ngx_int_t rc; | 864 ngx_int_t rc; |
865 | 865 |
866 /* | 866 /* |
867 * generic phase checker, | 867 * generic phase checker, |
868 * used by the post read, server rewrite, rewrite, and pre-access phases | 868 * used by the post read and pre-access phases |
869 */ | 869 */ |
870 | 870 |
871 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 871 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
872 "generic phase: %ui", r->phase_handler); | 872 "generic phase: %ui", r->phase_handler); |
873 | 873 |
886 if (rc == NGX_AGAIN || rc == NGX_DONE) { | 886 if (rc == NGX_AGAIN || rc == NGX_DONE) { |
887 return NGX_OK; | 887 return NGX_OK; |
888 } | 888 } |
889 | 889 |
890 /* rc == NGX_ERROR || rc == NGX_HTTP_... */ | 890 /* rc == NGX_ERROR || rc == NGX_HTTP_... */ |
891 | |
892 ngx_http_finalize_request(r, rc); | |
893 | |
894 return NGX_OK; | |
895 } | |
896 | |
897 | |
898 ngx_int_t | |
899 ngx_http_core_rewrite_phase(ngx_http_request_t *r, ngx_http_phase_handler_t *ph) | |
900 { | |
901 ngx_int_t rc; | |
902 | |
903 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
904 "rewrite phase: %ui", r->phase_handler); | |
905 | |
906 rc = ph->handler(r); | |
907 | |
908 if (rc == NGX_DECLINED) { | |
909 r->phase_handler++; | |
910 return NGX_AGAIN; | |
911 } | |
912 | |
913 /* rc == NGX_OK || rc == NGX_ERROR || rc == NGX_HTTP_... */ | |
891 | 914 |
892 ngx_http_finalize_request(r, rc); | 915 ngx_http_finalize_request(r, rc); |
893 | 916 |
894 return NGX_OK; | 917 return NGX_OK; |
895 } | 918 } |
1565 continue; | 1588 continue; |
1566 } | 1589 } |
1567 | 1590 |
1568 if (len == (size_t) node->len) { | 1591 if (len == (size_t) node->len) { |
1569 | 1592 |
1570 r->loc_conf = (node->exact) ? node->exact->loc_conf: | 1593 if (node->exact) { |
1571 node->inclusive->loc_conf; | 1594 r->loc_conf = node->exact->loc_conf; |
1572 return NGX_OK; | 1595 return NGX_OK; |
1596 | |
1597 } else { | |
1598 r->loc_conf = node->inclusive->loc_conf; | |
1599 return NGX_AGAIN; | |
1600 } | |
1573 } | 1601 } |
1574 | 1602 |
1575 /* len < node->len */ | 1603 /* len < node->len */ |
1576 | 1604 |
1577 if (len + 1 == (size_t) node->len && node->auto_redirect) { | 1605 if (len + 1 == (size_t) node->len && node->auto_redirect) { |
1703 return; | 1731 return; |
1704 } | 1732 } |
1705 } | 1733 } |
1706 | 1734 |
1707 return; | 1735 return; |
1736 } | |
1737 | |
1738 | |
1739 ngx_int_t | |
1740 ngx_http_send_response(ngx_http_request_t *r, ngx_uint_t status, | |
1741 ngx_str_t *ct, ngx_http_complex_value_t *cv) | |
1742 { | |
1743 ngx_int_t rc; | |
1744 ngx_str_t val; | |
1745 ngx_buf_t *b; | |
1746 ngx_chain_t out; | |
1747 | |
1748 r->headers_out.status = status; | |
1749 | |
1750 if (status == NGX_HTTP_NO_CONTENT) { | |
1751 return ngx_http_send_header(r); | |
1752 } | |
1753 | |
1754 if (ngx_http_complex_value(r, cv, &val) != NGX_OK) { | |
1755 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
1756 } | |
1757 | |
1758 if (status >= NGX_HTTP_MOVED_PERMANENTLY && status <= NGX_HTTP_SEE_OTHER) { | |
1759 | |
1760 r->headers_out.location = ngx_list_push(&r->headers_out.headers); | |
1761 if (r->headers_out.location == NULL) { | |
1762 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
1763 } | |
1764 | |
1765 r->headers_out.location->hash = 1; | |
1766 ngx_str_set(&r->headers_out.location->key, "Location"); | |
1767 r->headers_out.location->value = val; | |
1768 | |
1769 return status; | |
1770 } | |
1771 | |
1772 r->headers_out.content_length_n = val.len; | |
1773 | |
1774 if (ct) { | |
1775 r->headers_out.content_type_len = ct->len; | |
1776 r->headers_out.content_type = *ct; | |
1777 | |
1778 } else { | |
1779 if (ngx_http_set_content_type(r) != NGX_OK) { | |
1780 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
1781 } | |
1782 } | |
1783 | |
1784 if (r->method == NGX_HTTP_HEAD || (r != r->main && val.len == 0)) { | |
1785 return ngx_http_send_header(r); | |
1786 } | |
1787 | |
1788 b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t)); | |
1789 if (b == NULL) { | |
1790 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
1791 } | |
1792 | |
1793 b->pos = val.data; | |
1794 b->last = val.data + val.len; | |
1795 b->memory = val.len ? 1 : 0; | |
1796 b->last_buf = (r == r->main) ? 1 : 0; | |
1797 b->last_in_chain = 1; | |
1798 | |
1799 out.buf = b; | |
1800 out.next = NULL; | |
1801 | |
1802 rc = ngx_http_send_header(r); | |
1803 | |
1804 if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) { | |
1805 return rc; | |
1806 } | |
1807 | |
1808 return ngx_http_output_filter(r, &out); | |
1708 } | 1809 } |
1709 | 1810 |
1710 | 1811 |
1711 ngx_int_t | 1812 ngx_int_t |
1712 ngx_http_send_header(ngx_http_request_t *r) | 1813 ngx_http_send_header(ngx_http_request_t *r) |