diff options
author | Igor Sysoev <igor@sysoev.ru> | 2004-03-19 05:25:53 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2004-03-19 05:25:53 +0000 |
commit | ae02c19867083c6ad3e51506109cb37bca1d36d1 (patch) | |
tree | 195dbf63aa4155ca9161f096848fe06fbdc3ba6e /src/http/ngx_http_request.c | |
parent | da85f7f5fc233a10abf3cbcbda547c918b67fb27 (diff) | |
download | nginx-ae02c19867083c6ad3e51506109cb37bca1d36d1.tar.gz nginx-ae02c19867083c6ad3e51506109cb37bca1d36d1.zip |
nginx-0.0.3-2004-03-19-08:25:53 import
Diffstat (limited to 'src/http/ngx_http_request.c')
-rw-r--r-- | src/http/ngx_http_request.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index b69e79082..1e65a47bb 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -38,7 +38,8 @@ static char *client_header_errors[] = { "client %s sent invalid header, URL: %s", "client %s sent too long header line, URL: %s", "client %s sent HTTP/1.1 request without \"Host\" header, URL: %s", - "client %s sent invalid \"Content-Length\" header, URL: %s" + "client %s sent invalid \"Content-Length\" header, URL: %s", + "client %s wanted to send too large body: " SIZE_T_FMT " bytes, URL: %s" }; @@ -847,6 +848,21 @@ static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r) if (r->headers_in.content_length_n == NGX_ERROR) { return NGX_HTTP_PARSE_INVALID_CL_HEADER; } + + clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); + + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http cl: " SIZE_T_FMT " max: " SIZE_T_FMT, + r->headers_in.content_length_n, + clcf->client_max_body_size); + + if (clcf->client_max_body_size + && clcf->client_max_body_size + < (size_t) r->headers_in.content_length_n) + { + return NGX_HTTP_PARSE_ENTITY_TOO_LARGE; + } + } if (r->headers_in.connection) { @@ -884,8 +900,8 @@ void ngx_http_finalize_request(ngx_http_request_t *r, int rc) return; } - ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, - "http finalize request"); + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http finalize request: %d", rc); if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { @@ -1590,9 +1606,19 @@ static void ngx_http_client_error(ngx_http_request_t *r, r->connection->log->handler = NULL; if (ctx->url) { - ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, + if (client_error == NGX_HTTP_PARSE_ENTITY_TOO_LARGE) { + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, + client_header_errors[client_error - NGX_HTTP_CLIENT_ERROR], + ctx->client, r->headers_in.content_length_n, ctx->url); + + error = NGX_HTTP_REQUEST_ENTITY_TOO_LARGE; + r->lingering_close = 1; + + } else { + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, client_header_errors[client_error - NGX_HTTP_CLIENT_ERROR], ctx->client, ctx->url); + } } else { if (error == NGX_HTTP_REQUEST_URI_TOO_LARGE) { |