comparison src/http/ngx_http_request.c @ 335:d4241d7787fe

nginx-0.0.3-2004-05-14-20:51:47 import
author Igor Sysoev <igor@sysoev.ru>
date Fri, 14 May 2004 16:51:47 +0000
parents f168a88e93f7
children 6bdf858bff8c
comparison
equal deleted inserted replaced
334:af451db3fe99 335:d4241d7787fe
37 37
38 "client %s sent invalid header, URL: %s", 38 "client %s sent invalid header, URL: %s",
39 "client %s sent too long header line, URL: %s", 39 "client %s sent too long header line, URL: %s",
40 "client %s sent HTTP/1.1 request without \"Host\" header, URL: %s", 40 "client %s sent HTTP/1.1 request without \"Host\" header, URL: %s",
41 "client %s sent invalid \"Content-Length\" header, URL: %s", 41 "client %s sent invalid \"Content-Length\" header, URL: %s",
42 "client %s sent POST method without \"Content-Length\" header, URL: %s" 42 "client %s sent POST method without \"Content-Length\" header, URL: %s",
43 "client %s sent invalid \"Host\" header \"%s\", URL: %s"
43 }; 44 };
44 45
45 46
46 #if 0 47 #if 0
47 static void ngx_http_dummy(ngx_event_t *wev) 48 static void ngx_http_dummy(ngx_event_t *wev)
845 static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r) 846 static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r)
846 { 847 {
847 size_t len; 848 size_t len;
848 ngx_uint_t i; 849 ngx_uint_t i;
849 ngx_http_server_name_t *name; 850 ngx_http_server_name_t *name;
851 ngx_http_core_srv_conf_t *cscf;
850 ngx_http_core_loc_conf_t *clcf; 852 ngx_http_core_loc_conf_t *clcf;
851 853
852 if (r->headers_in.host) { 854 if (r->headers_in.host) {
853 for (len = 0; len < r->headers_in.host->value.len; len++) { 855 for (len = 0; len < r->headers_in.host->value.len; len++) {
854 if (r->headers_in.host->value.data[len] == ':') { 856 if (r->headers_in.host->value.data[len] == ':') {
876 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); 878 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
877 r->connection->log->file = clcf->err_log->file; 879 r->connection->log->file = clcf->err_log->file;
878 r->connection->log->log_level = clcf->err_log->log_level; 880 r->connection->log->log_level = clcf->err_log->log_level;
879 881
880 break; 882 break;
883 }
884 }
885
886 if (i == r->virtual_names->nelts) {
887 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
888
889 if (cscf->restrict_host_names != NGX_HTTP_RESTRICT_HOST_OFF) {
890 return NGX_HTTP_PARSE_INVALID_HOST;
881 } 891 }
882 } 892 }
883 893
884 } else { 894 } else {
885 if (r->http_version > NGX_HTTP_VERSION_10) { 895 if (r->http_version > NGX_HTTP_VERSION_10) {
1651 1661
1652 1662
1653 static void ngx_http_client_error(ngx_http_request_t *r, 1663 static void ngx_http_client_error(ngx_http_request_t *r,
1654 int client_error, int error) 1664 int client_error, int error)
1655 { 1665 {
1656 ngx_http_log_ctx_t *ctx; 1666 ngx_http_log_ctx_t *ctx;
1667 ngx_http_core_srv_conf_t *cscf;
1657 1668
1658 ctx = r->connection->log->data; 1669 ctx = r->connection->log->data;
1659 1670
1660 if (error == NGX_HTTP_REQUEST_TIME_OUT) { 1671 if (error == NGX_HTTP_REQUEST_TIME_OUT) {
1661 ngx_log_error(NGX_LOG_INFO, r->connection->log, NGX_ETIMEDOUT, 1672 ngx_log_error(NGX_LOG_INFO, r->connection->log, NGX_ETIMEDOUT,
1666 } 1677 }
1667 1678
1668 r->connection->log->handler = NULL; 1679 r->connection->log->handler = NULL;
1669 1680
1670 if (ctx->url) { 1681 if (ctx->url) {
1671 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, 1682 if (client_error == NGX_HTTP_PARSE_INVALID_HOST) {
1683 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
1684 client_header_errors[client_error - NGX_HTTP_CLIENT_ERROR],
1685 ctx->client, r->headers_in.host->value.data, ctx->url);
1686
1687 error = NGX_HTTP_INVALID_HOST;
1688
1689 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
1690
1691 if (cscf->restrict_host_names == NGX_HTTP_RESTRICT_HOST_CLOSE) {
1692 ngx_http_close_request(r, error);
1693 ngx_http_close_connection(r->connection);
1694 return;
1695 }
1696
1697 } else {
1698 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
1672 client_header_errors[client_error - NGX_HTTP_CLIENT_ERROR], 1699 client_header_errors[client_error - NGX_HTTP_CLIENT_ERROR],
1673 ctx->client, ctx->url); 1700 ctx->client, ctx->url);
1701 }
1674 1702
1675 } else { 1703 } else {
1676 if (error == NGX_HTTP_REQUEST_URI_TOO_LARGE) { 1704 if (error == NGX_HTTP_REQUEST_URI_TOO_LARGE) {
1677 r->request_line.len = r->header_in->end - r->request_start; 1705 r->request_line.len = r->header_in->end - r->request_start;
1678 r->request_line.data = r->request_start; 1706 r->request_line.data = r->request_start;