diff options
Diffstat (limited to 'src/http/modules')
| -rw-r--r-- | src/http/modules/ngx_http_gzip_filter.c | 15 | ||||
| -rw-r--r-- | src/http/modules/ngx_http_range_filter.c | 9 | ||||
| -rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.c | 52 | ||||
| -rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.h | 4 |
4 files changed, 48 insertions, 32 deletions
diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c index a32714da4..e9271a9b7 100644 --- a/src/http/modules/ngx_http_gzip_filter.c +++ b/src/http/modules/ngx_http_gzip_filter.c @@ -190,18 +190,23 @@ static int ngx_http_gzip_header_filter(ngx_http_request_t *r) sizeof(ngx_http_gzip_ctx_t), NGX_ERROR); ctx->request = r; - ngx_test_null(r->headers_out.content_encoding, - ngx_push_table(r->headers_out.headers), - NGX_ERROR); + if (!(r->headers_out.content_encoding = + ngx_http_add_header(&r->headers_out, ngx_http_headers_out))) + { + return NGX_ERROR; + } r->headers_out.content_encoding->key.len = 0; r->headers_out.content_encoding->key.data = NULL; - r->headers_out.content_encoding->value.len = 4; + r->headers_out.content_encoding->value.len = sizeof("gzip") - 1; r->headers_out.content_encoding->value.data = "gzip"; ctx->length = r->headers_out.content_length_n; r->headers_out.content_length_n = -1; - r->headers_out.content_length = NULL; + if (r->headers_out.content_length) { + r->headers_out.content_length->key.len = 0; + r->headers_out.content_length = NULL; + } r->filter |= NGX_HTTP_FILTER_NEED_IN_MEMORY; return ngx_http_next_header_filter(r); diff --git a/src/http/modules/ngx_http_range_filter.c b/src/http/modules/ngx_http_range_filter.c index 9233605a1..ff534bb9c 100644 --- a/src/http/modules/ngx_http_range_filter.c +++ b/src/http/modules/ngx_http_range_filter.c @@ -96,9 +96,12 @@ static int ngx_http_range_header_filter(ngx_http_request_t *r) || r->headers_in.range->value.len < 7 || ngx_strncasecmp(r->headers_in.range->value.data, "bytes=", 6) != 0) { - ngx_test_null(r->headers_out.accept_ranges, - ngx_push_table(r->headers_out.headers), - NGX_ERROR); + + if (!(r->headers_out.accept_ranges = + ngx_http_add_header(&r->headers_out, ngx_http_headers_out))) + { + return NGX_ERROR; + } r->headers_out.accept_ranges->key.len = sizeof("Accept-Ranges") - 1; r->headers_out.accept_ranges->key.data = "Accept-Ranges"; diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c index 8483cd7ae..50c199cd2 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.c +++ b/src/http/modules/proxy/ngx_http_proxy_handler.c @@ -475,6 +475,11 @@ static void ngx_http_proxy_send_request(ngx_http_proxy_ctx_t *p) /* rc == NGX_OK */ + if (c->read->ready) { + /* post aio operation */ + ngx_http_proxy_process_upstream_status_line(c->read); + } + if (ngx_handle_level_write_event(c->write) == NGX_ERROR) { ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR); @@ -742,8 +747,8 @@ static void ngx_http_proxy_process_upstream_headers(ngx_event_t *rev) } } - ngx_log_debug(c->log, "HTTP proxy header: '%s: %s'" _ - h->key.data _ h->value.data); + ngx_log_debug(c->log, "HTTP proxy header: %08X '%s: %s'" _ + h _ h->key.data _ h->value.data); continue; @@ -791,10 +796,6 @@ static ssize_t ngx_http_proxy_read_upstream_header(ngx_http_proxy_ctx_t *p) n = p->header_in->last - p->header_in->pos; if (n > 0) { -#if 0 - /* TODO THINK */ - rev->ready = 0; -#endif return n; } @@ -804,7 +805,7 @@ static ssize_t ngx_http_proxy_read_upstream_header(ngx_http_proxy_ctx_t *p) if (n == NGX_AGAIN) { ngx_add_timer(rev, p->lcf->read_timeout); - if (ngx_handle_read_event(rev) == NGX_ERROR) { + if (ngx_handle_read_event(rev, 0) == NGX_ERROR) { ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR); return NGX_ERROR; } @@ -829,10 +830,11 @@ static ssize_t ngx_http_proxy_read_upstream_header(ngx_http_proxy_ctx_t *p) static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p) { - int rc, i; - ngx_table_elt_t *ch, *ph; - ngx_event_pipe_t *ep; - ngx_http_request_t *r; + int rc, i; + ngx_table_elt_t *ch, *h; + ngx_event_pipe_t *ep; + ngx_http_request_t *r; + ngx_http_core_loc_conf_t *clcf; r = p->request; @@ -843,26 +845,26 @@ static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p) /* copy an upstream header to r->headers_out */ - ph = (ngx_table_elt_t *) p->headers_in.headers->elts; + h = p->headers_in.headers->elts; for (i = 0; i < p->headers_in.headers->nelts; i++) { - if (&ph[i] == p->headers_in.connection) { + if (&h[i] == p->headers_in.connection) { continue; } if (p->accel) { - if (&ph[i] == p->headers_in.date - || &ph[i] == p->headers_in.accept_ranges) { + if (&h[i] == p->headers_in.date + || &h[i] == p->headers_in.accept_ranges) { continue; } - if (&ph[i] == p->headers_in.server && !p->lcf->pass_server) { + if (&h[i] == p->headers_in.server && !p->lcf->pass_server) { continue; } } - if (&ph[i] == p->headers_in.content_type) { - r->headers_out.content_type = &ph[i]; + if (&h[i] == p->headers_in.content_type) { + r->headers_out.content_type = &h[i]; r->headers_out.content_type->key.len = 0; continue; } @@ -873,7 +875,7 @@ static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p) return; } - *ch = ph[i]; + *ch = h[i]; /* * ngx_http_header_filter() output the following headers @@ -883,17 +885,17 @@ static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p) * r->headers_out.content_length */ - if (&ph[i] == p->headers_in.server) { + if (&h[i] == p->headers_in.server) { r->headers_out.server = ch; continue; } - if (&ph[i] == p->headers_in.date) { + if (&h[i] == p->headers_in.date) { r->headers_out.date = ch; continue; } - if (&ph[i] == p->headers_in.content_length) { + if (&h[i] == p->headers_in.content_length) { r->headers_out.content_length_n = ngx_atoi(p->headers_in.content_length->value.data, @@ -977,6 +979,12 @@ static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p) r->sendfile = 1; } + clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); + + ep->read_timeout = p->lcf->read_timeout; + ep->send_timeout = clcf->send_timeout; + ep->send_lowat = clcf->send_lowat; + p->event_pipe = ep; p->upstream.connection->read->event_handler = ngx_http_proxy_process_body; diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.h b/src/http/modules/proxy/ngx_http_proxy_handler.h index f371cbc1c..601a8f6ca 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.h +++ b/src/http/modules/proxy/ngx_http_proxy_handler.h @@ -44,6 +44,8 @@ typedef struct { typedef struct { + ngx_table_t *headers; /* it must be first field */ + ngx_table_elt_t *date; ngx_table_elt_t *server; ngx_table_elt_t *connection; @@ -53,8 +55,6 @@ typedef struct { ngx_table_elt_t *accept_ranges; off_t content_length_n; - - ngx_table_t *headers; } ngx_http_proxy_headers_in_t; |
