aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_request.c
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2012-11-21 01:08:11 +0000
committerMaxim Dounin <mdounin@mdounin.ru>2012-11-21 01:08:11 +0000
commit5fc85439d0c6d55ff74ebba55d54d9c4e0bc6044 (patch)
tree63edb1b192543b176f856a3886e08e65d4205ab0 /src/http/ngx_http_request.c
parentd60b8d10f0d39510008d8f5017ee2bf259a488db (diff)
downloadnginx-5fc85439d0c6d55ff74ebba55d54d9c4e0bc6044.tar.gz
nginx-5fc85439d0c6d55ff74ebba55d54d9c4e0bc6044.zip
Request body: chunked transfer encoding support.
Diffstat (limited to 'src/http/ngx_http_request.c')
-rw-r--r--src/http/ngx_http_request.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index ef010ff57..e94e7fcce 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1574,19 +1574,11 @@ ngx_http_process_request_header(ngx_http_request_t *r)
if (r->headers_in.content_length_n == NGX_ERROR) {
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
"client sent invalid \"Content-Length\" header");
- ngx_http_finalize_request(r, NGX_HTTP_LENGTH_REQUIRED);
+ ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
return NGX_ERROR;
}
}
- if (r->method & NGX_HTTP_PUT && r->headers_in.content_length_n == -1) {
- ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
- "client sent %V method without \"Content-Length\" header",
- &r->method_name);
- ngx_http_finalize_request(r, NGX_HTTP_LENGTH_REQUIRED);
- return NGX_ERROR;
- }
-
if (r->method & NGX_HTTP_TRACE) {
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
"client sent TRACE method");
@@ -1594,14 +1586,25 @@ ngx_http_process_request_header(ngx_http_request_t *r)
return NGX_ERROR;
}
- if (r->headers_in.transfer_encoding
- && ngx_strcasestrn(r->headers_in.transfer_encoding->value.data,
- "chunked", 7 - 1))
- {
- ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
- "client sent \"Transfer-Encoding: chunked\" header");
- ngx_http_finalize_request(r, NGX_HTTP_LENGTH_REQUIRED);
- return NGX_ERROR;
+ if (r->headers_in.transfer_encoding) {
+ if (r->headers_in.transfer_encoding->value.len == 7
+ && ngx_strncasecmp(r->headers_in.transfer_encoding->value.data,
+ (u_char *) "chunked", 7) == 0)
+ {
+ r->headers_in.content_length = NULL;
+ r->headers_in.content_length_n = -1;
+ r->headers_in.chunked = 1;
+
+ } else if (r->headers_in.transfer_encoding->value.len != 8
+ || ngx_strncasecmp(r->headers_in.transfer_encoding->value.data,
+ (u_char *) "identity", 8) != 0)
+ {
+ ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
+ "client sent unknown \"Transfer-Encoding\": \"%V\"",
+ &r->headers_in.transfer_encoding->value);
+ ngx_http_finalize_request(r, NGX_HTTP_NOT_IMPLEMENTED);
+ return NGX_ERROR;
+ }
}
if (r->headers_in.connection_type == NGX_HTTP_CONNECTION_KEEP_ALIVE) {