nginx-0.0.1-2003-11-19-00:34:08 import
diff --git a/src/http/modules/ngx_http_static_handler.c b/src/http/modules/ngx_http_static_handler.c
index c922870..69f1a14 100644
--- a/src/http/modules/ngx_http_static_handler.c
+++ b/src/http/modules/ngx_http_static_handler.c
@@ -200,8 +200,10 @@
*last++ = '/';
*last = '\0';
+#if 0
r->headers_out.location->key.len = 8;
r->headers_out.location->key.data = "Location" ;
+#endif
r->headers_out.location->value.len = last - location;
r->headers_out.location->value.data = location;
diff --git a/src/http/modules/proxy/ngx_http_proxy_cache.c b/src/http/modules/proxy/ngx_http_proxy_cache.c
index 28ffde1..958471b 100644
--- a/src/http/modules/proxy/ngx_http_proxy_cache.c
+++ b/src/http/modules/proxy/ngx_http_proxy_cache.c
@@ -55,6 +55,7 @@
p->header_in->tag = (ngx_hunk_tag_t) &ngx_http_proxy_module;
c->ctx.buf = p->header_in;
+ c->ctx.log = r->connection->log;
return ngx_http_proxy_process_cached_response(p,
ngx_http_cache_get_file(r, &c->ctx));
@@ -341,8 +342,7 @@
*ctx = p->cache->ctx;
- rc = ngx_http_cache_open_file(p->request, ctx,
- ngx_file_uniq(&p->cache->ctx.file.info));
+ rc = ngx_http_cache_open_file(ctx, ngx_file_uniq(&p->cache->ctx.file.info));
if (rc == NGX_HTTP_CACHE_THE_SAME) {
p->try_busy_lock = 1;
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c
index 83b9066..7a012c8 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.c
@@ -114,14 +114,14 @@
ngx_conf_set_path_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_proxy_loc_conf_t, cache_path),
- NULL },
+ ngx_garbage_collector_http_cache_handler },
{ ngx_string("proxy_temp_path"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234,
ngx_conf_set_path_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_proxy_loc_conf_t, temp_path),
- NULL },
+ ngx_garbage_collector_temp_handler },
{ ngx_string("proxy_temp_file_write_size"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
@@ -255,6 +255,8 @@
offsetof(ngx_http_proxy_headers_in_t, content_length) },
{ ngx_string("Last-Modified"),
offsetof(ngx_http_proxy_headers_in_t, last_modified) },
+ { ngx_string("Location"),
+ offsetof(ngx_http_proxy_headers_in_t, location) },
{ ngx_string("Accept-Ranges"),
offsetof(ngx_http_proxy_headers_in_t, accept_ranges) },
@@ -932,6 +934,7 @@
clcf = ctx->loc_conf[ngx_http_core_module.ctx_index];
lcf->upstream->location = &clcf->name;
clcf->handler = ngx_http_proxy_handler;
+ clcf->auto_redirect = 1;
return NULL;
}
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.h b/src/http/modules/proxy/ngx_http_proxy_handler.h
index e822a3f..0258de5 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.h
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.h
@@ -116,6 +116,7 @@
ngx_table_elt_t *content_type;
ngx_table_elt_t *content_length;
ngx_table_elt_t *last_modified;
+ ngx_table_elt_t *location;
ngx_table_elt_t *accept_ranges;
off_t content_length_n;
diff --git a/src/http/modules/proxy/ngx_http_proxy_header.c b/src/http/modules/proxy/ngx_http_proxy_header.c
index 4dda797..76d3321 100644
--- a/src/http/modules/proxy/ngx_http_proxy_header.c
+++ b/src/http/modules/proxy/ngx_http_proxy_header.c
@@ -5,6 +5,9 @@
#include <ngx_http_proxy_handler.h>
+static int ngx_http_proxy_rewrite_location_header(ngx_http_proxy_ctx_t *p,
+ ngx_table_elt_t *loc);
+
int ngx_http_proxy_copy_header(ngx_http_proxy_ctx_t *p,
ngx_http_proxy_headers_in_t *headers_in)
{
@@ -36,6 +39,16 @@
if (&h[i] == headers_in->server && !p->lcf->pass_server) {
continue;
}
+
+ if (&h[i] == headers_in->location) {
+ if (ngx_http_proxy_rewrite_location_header(p, &h[i])
+ == NGX_ERROR)
+ {
+ return NGX_ERROR;
+ }
+
+ continue;
+ }
}
if (&h[i] == headers_in->content_type) {
@@ -79,3 +92,47 @@
return NGX_OK;
}
+
+
+static int ngx_http_proxy_rewrite_location_header(ngx_http_proxy_ctx_t *p,
+ ngx_table_elt_t *loc)
+{
+ char *last;
+ 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) {
+ return NGX_ERROR;
+ }
+
+ if (uc->url.len > loc->value.len
+ || ngx_rstrncmp(loc->value.data, uc->url.data, uc->url.len) != 0)
+ {
+ *r->headers_out.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) {
+ return NGX_ERROR;
+ }
+
+ last = ngx_cpymem(r->headers_out.location->value.data,
+ uc->location->data, uc->location->len);
+
+ ngx_cpystrn(last, loc->value.data + uc->url.len,
+ loc->value.len - uc->url.len + 1);
+
+ return NGX_OK;
+}
diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c
index 135050e..12a4c62 100644
--- a/src/http/modules/proxy/ngx_http_proxy_upstream.c
+++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c
@@ -1182,8 +1182,8 @@
}
if (p->request->connection->write->eof) {
- ngx_http_proxy_finalize_request(p, status ? status:
- NGX_HTTP_CLIENT_CLOSED_REQUEST);
+ ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST);
+ return;
}
if (status) {