summaryrefslogtreecommitdiffhomepage
path: root/src/http/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/modules')
-rw-r--r--src/http/modules/ngx_http_chunked_filter.c40
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_handler.c1
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_handler.h1
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_header.c4
4 files changed, 36 insertions, 10 deletions
diff --git a/src/http/modules/ngx_http_chunked_filter.c b/src/http/modules/ngx_http_chunked_filter.c
index 61eae5d3c..3cd6dddcf 100644
--- a/src/http/modules/ngx_http_chunked_filter.c
+++ b/src/http/modules/ngx_http_chunked_filter.c
@@ -66,12 +66,16 @@ static int ngx_http_chunked_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
}
ngx_test_null(out, ngx_alloc_chain_link(r->pool), NGX_ERROR);
+ out->hunk = NULL;
ll = &out->next;
size = 0;
cl = in;
for ( ;; ) {
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http chunk: %d", ngx_hunk_size(cl->hunk));
+
size += ngx_hunk_size(cl->hunk);
ngx_test_null(tl, ngx_alloc_chain_link(r->pool), NGX_ERROR);
@@ -86,25 +90,41 @@ static int ngx_http_chunked_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
cl = cl->next;
}
- ngx_test_null(chunk, ngx_palloc(r->pool, 11), NGX_ERROR);
- len = ngx_snprintf((char *) chunk, 11, SIZE_T_X_FMT CRLF, size);
-
- ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
- h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP;
- h->pos = chunk;
- h->last = chunk + len;
+ if (size) {
+ ngx_test_null(chunk, ngx_palloc(r->pool, 11), NGX_ERROR);
+ len = ngx_snprintf((char *) chunk, 11, SIZE_T_X_FMT CRLF, size);
- out->hunk = h;
+ ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
+ h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP;
+ h->pos = chunk;
+ h->last = chunk + len;
- ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
+ out->hunk = h;
+ }
if (cl->hunk->type & NGX_HUNK_LAST) {
- cl->hunk->type &= ~NGX_HUNK_LAST;
+
+ ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_MEMORY|NGX_HUNK_LAST;
h->pos = (u_char *) CRLF "0" CRLF CRLF;
h->last = h->pos + 7;
+ cl->hunk->type &= ~NGX_HUNK_LAST;
+
+ if (size == 0) {
+ out->hunk = h;
+ out->next = NULL;
+
+ return ngx_http_next_body_filter(r, out);
+ }
+
} else {
+ if (size == 0) {
+ *ll = NULL;
+ return ngx_http_next_body_filter(r, out->next);
+ }
+
+ ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_MEMORY;
h->pos = (u_char *) CRLF;
h->last = h->pos + 2;
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c
index 8aa339772..d523fc1ab 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.c
@@ -278,6 +278,7 @@ ngx_http_header_t ngx_http_proxy_headers_in[] = {
offsetof(ngx_http_proxy_headers_in_t, location) },
{ ngx_string("Accept-Ranges"),
offsetof(ngx_http_proxy_headers_in_t, accept_ranges) },
+ { ngx_string("X-Pad"), offsetof(ngx_http_proxy_headers_in_t, x_pad) },
{ ngx_null_string, 0 }
};
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.h b/src/http/modules/proxy/ngx_http_proxy_handler.h
index 55eee74e9..e0f85ee20 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.h
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.h
@@ -123,6 +123,7 @@ typedef struct {
ngx_table_elt_t *last_modified;
ngx_table_elt_t *location;
ngx_table_elt_t *accept_ranges;
+ ngx_table_elt_t *x_pad;
off_t content_length_n;
} ngx_http_proxy_headers_in_t;
diff --git a/src/http/modules/proxy/ngx_http_proxy_header.c b/src/http/modules/proxy/ngx_http_proxy_header.c
index cb13034f7..a3e05e513 100644
--- a/src/http/modules/proxy/ngx_http_proxy_header.c
+++ b/src/http/modules/proxy/ngx_http_proxy_header.c
@@ -26,6 +26,10 @@ int ngx_http_proxy_copy_header(ngx_http_proxy_ctx_t *p,
continue;
}
+ if (&h[i] == headers_in->x_pad) {
+ continue;
+ }
+
if (p->accel) {
if (&h[i] == headers_in->date
|| &h[i] == headers_in->accept_ranges) {