comparison src/http/ngx_http_core_module.c @ 438:ce4f9ff90bfa NGINX_0_7_31

nginx 0.7.31 *) Change: now the "try_files" directive tests files only and ignores directories. *) Feature: the "fastcgi_split_path_info" directive. *) Bugfixes in an "Expect" request header line support. *) Bugfixes in geo ranges. *) Bugfix: in a miss case ngx_http_memcached_module returned the "END" line as response body instead of default 404 page body; the bug had appeared in 0.7.18. Thanks to Maxim Dounin. *) Bugfix: while SMTP proxying nginx issued message "250 2.0.0 OK" instead of "235 2.0.0 OK"; the bug had appeared in 0.7.22. Thanks to Maxim Dounin.
author Igor Sysoev <http://sysoev.ru>
date Mon, 19 Jan 2009 00:00:00 +0300
parents 49a0eb7ce20c
children 6281966854a5
comparison
equal deleted inserted replaced
437:5da91f7cde93 438:ce4f9ff90bfa
21 21
22 22
23 static ngx_int_t ngx_http_core_find_location(ngx_http_request_t *r); 23 static ngx_int_t ngx_http_core_find_location(ngx_http_request_t *r);
24 static ngx_int_t ngx_http_core_find_static_location(ngx_http_request_t *r, 24 static ngx_int_t ngx_http_core_find_static_location(ngx_http_request_t *r,
25 ngx_http_location_tree_node_t *node); 25 ngx_http_location_tree_node_t *node);
26 static ngx_int_t ngx_http_core_send_continue(ngx_http_request_t *r);
27 26
28 static ngx_int_t ngx_http_core_preconfiguration(ngx_conf_t *cf); 27 static ngx_int_t ngx_http_core_preconfiguration(ngx_conf_t *cf);
29 static void *ngx_http_core_create_main_conf(ngx_conf_t *cf); 28 static void *ngx_http_core_create_main_conf(ngx_conf_t *cf);
30 static char *ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf); 29 static char *ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf);
31 static void *ngx_http_core_create_srv_conf(ngx_conf_t *cf); 30 static void *ngx_http_core_create_srv_conf(ngx_conf_t *cf);
816 ngx_http_core_find_config_phase(ngx_http_request_t *r, 815 ngx_http_core_find_config_phase(ngx_http_request_t *r,
817 ngx_http_phase_handler_t *ph) 816 ngx_http_phase_handler_t *ph)
818 { 817 {
819 u_char *p; 818 u_char *p;
820 size_t len; 819 size_t len;
821 ngx_int_t rc, expect; 820 ngx_int_t rc;
822 ngx_http_core_loc_conf_t *clcf; 821 ngx_http_core_loc_conf_t *clcf;
823 822
824 r->content_handler = NULL; 823 r->content_handler = NULL;
825 r->uri_changed = 0; 824 r->uri_changed = 0;
826 825
858 "client intended to send too large body: %O bytes", 857 "client intended to send too large body: %O bytes",
859 r->headers_in.content_length_n); 858 r->headers_in.content_length_n);
860 859
861 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_ENTITY_TOO_LARGE); 860 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_ENTITY_TOO_LARGE);
862 return NGX_OK; 861 return NGX_OK;
863 }
864
865 if (r->headers_in.expect && r->http_version > NGX_HTTP_VERSION_10) {
866 expect = ngx_http_core_send_continue(r);
867
868 if (expect != NGX_OK) {
869 ngx_http_finalize_request(r, expect);
870 return NGX_OK;
871 }
872 } 862 }
873 863
874 if (rc == NGX_DONE) { 864 if (rc == NGX_DONE) {
875 r->headers_out.location = ngx_list_push(&r->headers_out.headers); 865 r->headers_out.location = ngx_list_push(&r->headers_out.headers);
876 if (r->headers_out.location == NULL) { 866 if (r->headers_out.location == NULL) {
1180 } 1170 }
1181 1171
1182 continue; 1172 continue;
1183 } 1173 }
1184 1174
1175 if (!of.is_file) {
1176 continue;
1177 }
1178
1185 path.len -= root; 1179 path.len -= root;
1186 path.data += root; 1180 path.data += root;
1187 1181
1188 if (!alias) { 1182 if (!alias) {
1189 r->uri = path; 1183 r->uri = path;
1488 node = node->left; 1482 node = node->left;
1489 } 1483 }
1490 } 1484 }
1491 1485
1492 1486
1493 static ngx_int_t
1494 ngx_http_core_send_continue(ngx_http_request_t *r)
1495 {
1496 ngx_int_t n;
1497 ngx_str_t *expect;
1498
1499 if (r->expect_tested) {
1500 return NGX_OK;
1501 }
1502
1503 r->expect_tested = 1;
1504
1505 expect = &r->headers_in.expect->value;
1506
1507 if (expect->len != sizeof("100-continue") - 1
1508 || ngx_strncasecmp(expect->data, (u_char *) "100-continue",
1509 sizeof("100-continue") - 1)
1510 != 0)
1511 {
1512 return NGX_OK;
1513 }
1514
1515 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1516 "send 100 Continue");
1517
1518 n = r->connection->send(r->connection,
1519 (u_char *) "HTTP/1.1 100 Continue" CRLF CRLF,
1520 sizeof("HTTP/1.1 100 Continue" CRLF CRLF) - 1);
1521
1522 if (n == sizeof("HTTP/1.1 100 Continue" CRLF CRLF) - 1) {
1523 return NGX_OK;
1524 }
1525
1526 /* we assume that such small packet should be send successfully */
1527
1528 return NGX_HTTP_INTERNAL_SERVER_ERROR;
1529 }
1530
1531
1532 void * 1487 void *
1533 ngx_http_test_content_type(ngx_http_request_t *r, ngx_hash_t *types_hash) 1488 ngx_http_test_content_type(ngx_http_request_t *r, ngx_hash_t *types_hash)
1534 { 1489 {
1535 u_char c, *p; 1490 u_char c, *p;
1536 ngx_uint_t i, hash; 1491 ngx_uint_t i, hash;
2123 } 2078 }
2124 2079
2125 sr->internal = 1; 2080 sr->internal = 1;
2126 2081
2127 sr->discard_body = r->discard_body; 2082 sr->discard_body = r->discard_body;
2083 sr->expect_tested = 1;
2128 sr->main_filter_need_in_memory = r->main_filter_need_in_memory; 2084 sr->main_filter_need_in_memory = r->main_filter_need_in_memory;
2129 2085
2130 sr->uri_changes = NGX_HTTP_MAX_URI_CHANGES + 1; 2086 sr->uri_changes = NGX_HTTP_MAX_URI_CHANGES + 1;
2131 2087
2132 r->main->subrequests++; 2088 r->main->subrequests++;