From 7a63f1ba3578cf4ade822bb063353fc3d1dd3e6b Mon Sep 17 00:00:00 2001 From: Kirill A. Korinskiy Date: Wed, 4 Mar 2009 15:21:28 +0300 Subject: [PATCH 1/4] Setting `r->headers_out.content_length_n' to 0 if enabled keep-alive Cc: catap@catap.ru `ngx_http_header_filter' remove contet length header if `r->status' have 204 and `r->headers_out.content_length_n' 0 or `r->headers_only' `r->zero_body' is enabled. Signed-off-by: Kirill A. Korinskiy --- src/http/ngx_http_header_filter_module.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/src/http/ngx_http_header_filter_module.c b/src/http/ngx_http_header_filter_module.c index 1874b57830b9ccc329863dce58ee7f0d8e154396..e07eda84dd09b0eb227bfcc8ad6c2eb0e6a968a5 100644 --- a/src/http/ngx_http_header_filter_module.c +++ b/src/http/ngx_http_header_filter_module.c @@ -245,6 +245,11 @@ ngx_http_header_filter(ngx_http_request_t *r) len += ngx_http_status_lines[status].len; } + if (r->keepalive && r->headers_out.content_length_n == -1) { + r->headers_out.content_length = NULL; + r->headers_out.content_length_n = 0; + } + clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); if (r->headers_out.server == NULL) { -- 1.6.2 From 542aaae0db8114e6b562543f9d6462d1b349af8b Mon Sep 17 00:00:00 2001 From: Kirill A. Korinskiy Date: Fri, 15 May 2009 04:36:24 +0400 Subject: [PATCH 2/4] Close connection if not set `content_length_n' and don't have chunked encoding. Cc: catap@catap.ru Signed-off-by: Kirill A. Korinskiy --- src/http/ngx_http_header_filter_module.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/http/ngx_http_header_filter_module.c b/src/http/ngx_http_header_filter_module.c index e07eda84dd09b0eb227bfcc8ad6c2eb0e6a968a5..4e8f17ac133131ed7a60de89e89a75b02342c395 100644 --- a/src/http/ngx_http_header_filter_module.c +++ b/src/http/ngx_http_header_filter_module.c @@ -245,9 +245,8 @@ ngx_http_header_filter(ngx_http_request_t *r) len += ngx_http_status_lines[status].len; } - if (r->keepalive && r->headers_out.content_length_n == -1) { - r->headers_out.content_length = NULL; - r->headers_out.content_length_n = 0; + if (!r->chunked && r->keepalive && r->headers_out.content_length_n == -1) { + r->keepalive = 0; } clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); -- 1.6.2 From ea7660749ea2c8c1bd16a1d42a68c251d3daa5ed Mon Sep 17 00:00:00 2001 From: Kirill A. Korinskiy Date: Fri, 15 May 2009 22:34:10 +0400 Subject: [PATCH 3/4] Setting content-length: 0 only for No Content Cc: catap@catap.ru Signed-off-by: Kirill A. Korinskiy --- src/http/ngx_http_header_filter_module.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-) diff --git a/src/http/ngx_http_header_filter_module.c b/src/http/ngx_http_header_filter_module.c index 4e8f17ac133131ed7a60de89e89a75b02342c395..3abc4a79328131b0a3c441f12dd66207ede78c28 100644 --- a/src/http/ngx_http_header_filter_module.c +++ b/src/http/ngx_http_header_filter_module.c @@ -216,7 +216,7 @@ ngx_http_header_filter(ngx_http_request_t *r) r->headers_out.last_modified_time = -1; r->headers_out.last_modified = NULL; r->headers_out.content_length = NULL; - r->headers_out.content_length_n = -1; + r->headers_out.content_length_n = 0; } } else if (r->headers_out.status < NGX_HTTP_BAD_REQUEST) { @@ -245,10 +245,6 @@ ngx_http_header_filter(ngx_http_request_t *r) len += ngx_http_status_lines[status].len; } - if (!r->chunked && r->keepalive && r->headers_out.content_length_n == -1) { - r->keepalive = 0; - } - clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); if (r->headers_out.server == NULL) { -- 1.6.2 From f3089c77b07a00ed3cb5f90b5a72d15dbc2bb187 Mon Sep 17 00:00:00 2001 From: Kirill A. Korinskiy Date: Sat, 16 May 2009 15:58:55 +0400 Subject: [PATCH 4/4] Close connection for No Content response if don't havehave chunked encoding. Cc: catap@catap.ru --- src/http/ngx_http_header_filter_module.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/src/http/ngx_http_header_filter_module.c b/src/http/ngx_http_header_filter_module.c index 3abc4a79328131b0a3c441f12dd66207ede78c28..ae778853a4ea8fc5ccdd48b0fcd03b5783255245 100644 --- a/src/http/ngx_http_header_filter_module.c +++ b/src/http/ngx_http_header_filter_module.c @@ -216,7 +216,10 @@ ngx_http_header_filter(ngx_http_request_t *r) r->headers_out.last_modified_time = -1; r->headers_out.last_modified = NULL; r->headers_out.content_length = NULL; - r->headers_out.content_length_n = 0; + r->headers_out.content_length_n = -1; + if (!r->chunked) { + r->keepalive = 0; + } } } else if (r->headers_out.status < NGX_HTTP_BAD_REQUEST) { -- 1.6.2