diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2004-03-23 06:01:52 +0000 |
|---|---|---|
| committer | Igor Sysoev <igor@sysoev.ru> | 2004-03-23 06:01:52 +0000 |
| commit | 89690bfe02703853c3e987d1e5c4d9878c4d28f0 (patch) | |
| tree | c5d9a59cdd74b54ffa939dcf59886307f26c984c /src/http/modules | |
| parent | ae02c19867083c6ad3e51506109cb37bca1d36d1 (diff) | |
| download | nginx-89690bfe02703853c3e987d1e5c4d9878c4d28f0.tar.gz nginx-89690bfe02703853c3e987d1e5c4d9878c4d28f0.tar.bz2 | |
nginx-0.0.3-2004-03-23-09:01:52 import
Diffstat (limited to 'src/http/modules')
| -rw-r--r-- | src/http/modules/ngx_http_gzip_filter.c | 8 | ||||
| -rw-r--r-- | src/http/modules/ngx_http_static_handler.c | 2 | ||||
| -rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.h | 2 | ||||
| -rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_header.c | 32 | ||||
| -rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_upstream.c | 37 |
5 files changed, 49 insertions, 32 deletions
diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c index a1cbfb042..a1640bd2c 100644 --- a/src/http/modules/ngx_http_gzip_filter.c +++ b/src/http/modules/ngx_http_gzip_filter.c @@ -32,7 +32,7 @@ typedef struct { void *preallocated; char *free_mem; - int allocated; + ngx_uint_t allocated; unsigned flush:4; unsigned redo:1; @@ -515,8 +515,8 @@ static void *ngx_http_gzip_filter_alloc(void *opaque, u_int items, u_int size) { ngx_http_gzip_ctx_t *ctx = opaque; - int alloc; - void *p; + void *p; + ngx_uint_t alloc; alloc = items * size; if (alloc % 512 != 0) { @@ -533,7 +533,7 @@ static void *ngx_http_gzip_filter_alloc(void *opaque, u_int items, u_int size) ctx->allocated -= alloc; ngx_log_debug4(NGX_LOG_DEBUG_HTTP, ctx->request->connection->log, 0, - "gzip alloc: n:%d s:%d a:%d p:%08X", + "gzip alloc: n:%d s:%d a:%d p:" PTR_FMT, items, size, alloc, p); return p; diff --git a/src/http/modules/ngx_http_static_handler.c b/src/http/modules/ngx_http_static_handler.c index 0576255eb..ae1b8170d 100644 --- a/src/http/modules/ngx_http_static_handler.c +++ b/src/http/modules/ngx_http_static_handler.c @@ -89,7 +89,7 @@ static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r) rc = ngx_http_discard_body(r); - if (rc != NGX_OK) { + if (rc != NGX_OK && rc != NGX_AGAIN) { return rc; } diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.h b/src/http/modules/proxy/ngx_http_proxy_handler.h index ee95f1b44..210ca89f8 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.h +++ b/src/http/modules/proxy/ngx_http_proxy_handler.h @@ -108,7 +108,7 @@ typedef struct { typedef struct { - ngx_table_t *headers; /* it must be first field */ + ngx_table_t headers; /* it must be first field */ ngx_table_elt_t *date; ngx_table_elt_t *server; diff --git a/src/http/modules/proxy/ngx_http_proxy_header.c b/src/http/modules/proxy/ngx_http_proxy_header.c index 66a6bfe01..8c24a065e 100644 --- a/src/http/modules/proxy/ngx_http_proxy_header.c +++ b/src/http/modules/proxy/ngx_http_proxy_header.c @@ -17,8 +17,8 @@ int ngx_http_proxy_copy_header(ngx_http_proxy_ctx_t *p, r = p->request; - h = headers_in->headers->elts; - for (i = 0; i < headers_in->headers->nelts; i++) { + h = headers_in->headers.elts; + for (i = 0; i < headers_in->headers.nelts; i++) { if (&h[i] == headers_in->connection) { continue; @@ -98,37 +98,43 @@ static int ngx_http_proxy_rewrite_location_header(ngx_http_proxy_ctx_t *p, ngx_table_elt_t *loc) { u_char *last; + ngx_table_elt_t *location; ngx_http_request_t *r; ngx_http_proxy_upstream_conf_t *uc; r = p->request; uc = p->lcf->upstream; - r->headers_out.location = ngx_http_add_header(&r->headers_out, - ngx_http_headers_out); - if (r->headers_out.location == NULL) { + location = ngx_http_add_header(&r->headers_out, ngx_http_headers_out); + if (location == NULL) { return NGX_ERROR; } + /* + * we do not set r->headers_out.location to avoid the handling + * the local redirects without a host name by ngx_http_header_filter() + */ + +#if 0 + r->headers_out.location = location; +#endif + if (uc->url.len > loc->value.len || ngx_rstrncmp(loc->value.data, uc->url.data, uc->url.len) != 0) { - *r->headers_out.location = *loc; + *location = *loc; return NGX_OK; } /* TODO: proxy_reverse */ - r->headers_out.location->value.len = uc->location->len - + (loc->value.len - uc->url.len) + 1; - r->headers_out.location->value.data = - ngx_palloc(r->pool, r->headers_out.location->value.len); - - if (r->headers_out.location->value.data == NULL) { + location->value.len = uc->location->len + + (loc->value.len - uc->url.len) + 1; + if (!(location->value.data = ngx_palloc(r->pool, location->value.len))) { return NGX_ERROR; } - last = ngx_cpymem(r->headers_out.location->value.data, + last = ngx_cpymem(location->value.data, uc->location->data, uc->location->len); ngx_cpystrn(last, loc->value.data + uc->url.len, diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c index d72f09e0b..68c957408 100644 --- a/src/http/modules/proxy/ngx_http_proxy_upstream.c +++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c @@ -148,8 +148,8 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p) } - header = (ngx_table_elt_t *) r->headers_in.headers->elts; - for (i = 0; i < r->headers_in.headers->nelts; i++) { + header = r->headers_in.headers.elts; + for (i = 0; i < r->headers_in.headers.nelts; i++) { if (&header[i] == r->headers_in.host) { continue; @@ -198,7 +198,7 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p) h->last = ngx_cpymem(h->last, host_header, sizeof(host_header) - 1); - if (p->lcf->preserve_host) { + if (p->lcf->preserve_host && r->headers_in.host) { h->last = ngx_cpymem(h->last, r->headers_in.host->value.data, r->headers_in.host_name_len); @@ -250,7 +250,7 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p) } - for (i = 0; i < r->headers_in.headers->nelts; i++) { + for (i = 0; i < r->headers_in.headers.nelts; i++) { if (&header[i] == r->headers_in.host) { continue; @@ -377,7 +377,7 @@ static void ngx_http_proxy_init_upstream(void *data) return; } - output->output_ctx = writer; + output->filter_ctx = writer; writer->pool = r->pool; if (p->lcf->busy_lock && !p->busy_locked) { @@ -392,7 +392,6 @@ static void ngx_http_proxy_reinit_upstream(ngx_http_proxy_ctx_t *p) { ngx_chain_t *cl; ngx_output_chain_ctx_t *output; - ngx_chain_writer_ctx_t *writer; output = p->upstream->output_chain_ctx; @@ -400,6 +399,7 @@ static void ngx_http_proxy_reinit_upstream(ngx_http_proxy_ctx_t *p) for (cl = p->request->request_hunks; cl; cl = cl->next) { cl->hunk->pos = cl->hunk->start; + cl->hunk->file_pos = 0; } /* reinit the ngx_output_chain() context */ @@ -521,7 +521,7 @@ static void ngx_http_proxy_connect(ngx_http_proxy_ctx_t *p) /* init or reinit the ngx_output_chain() and ngx_chain_writer() contexts */ output = p->upstream->output_chain_ctx; - writer = output->output_ctx; + writer = output->filter_ctx; writer->out = NULL; writer->last = &writer->out; writer->connection = c; @@ -541,7 +541,6 @@ static void ngx_http_proxy_connect(ngx_http_proxy_ctx_t *p) output->hunks = 1; r->request_body_hunk->pos = r->request_body_hunk->start; - r->request_body_hunk->last = r->request_body_hunk->start; } p->request_sent = 0; @@ -824,14 +823,26 @@ static void ngx_http_proxy_process_upstream_status_line(ngx_event_t *rev) "http proxy status %d \"%s\"", p->upstream->status, p->upstream->status_line.data); - if (p->upstream->headers_in.headers) { - p->upstream->headers_in.headers->nelts = 0; + + /* init or reinit the p->upstream->headers_in.headers table */ + + if (p->upstream->headers_in.headers.elts) { + p->upstream->headers_in.headers.nelts = 0; + } else { - /* TODO: ngx_init_table */ - p->upstream->headers_in.headers = ngx_create_table(p->request->pool, - 20); + p->upstream->headers_in.headers.elts = ngx_pcalloc(p->request->pool, + 20 * sizeof(ngx_table_elt_t)); + if (p->upstream->headers_in.headers.elts == NULL) { + ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR); + return; + } + /* p->upstream->headers_in.headers.nelts = 0; */ + p->upstream->headers_in.headers.nalloc = 20; + p->upstream->headers_in.headers.size = sizeof(ngx_table_elt_t); + p->upstream->headers_in.headers.pool = p->request->pool; } + c->read->event_handler = ngx_http_proxy_process_upstream_headers; ngx_http_proxy_process_upstream_headers(rev); } |
