nginx-0.0.1-2003-11-19-19:26:41 import
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c
index 7a012c8..b7487f8 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.c
@@ -524,22 +524,22 @@
size_t ngx_http_proxy_log_error(void *data, char *buf, size_t len)
{
- ngx_http_proxy_ctx_t *p = data;
+ ngx_http_proxy_log_ctx_t *ctx = data;
ngx_http_request_t *r;
ngx_peer_connection_t *peer;
- r = p->request;
- peer = &p->upstream->peer;
+ r = ctx->proxy->request;
+ peer = &ctx->proxy->upstream->peer;
return ngx_snprintf(buf, len,
" while %s, client: %s, URL: %s, upstream: %s%s%s%s%s",
- p->action,
+ ctx->proxy->action,
r->connection->addr_text.data,
r->unparsed_uri.data,
peer->peers->peers[peer->cur_peer].addr_port_text.data,
- p->lcf->upstream->uri.data,
- r->uri.data + p->lcf->upstream->location->len,
+ ctx->proxy->lcf->upstream->uri.data,
+ r->uri.data + ctx->proxy->lcf->upstream->location->len,
r->args.len ? "?" : "",
r->args.len ? r->args.data : "");
}
@@ -934,7 +934,9 @@
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;
+ if (clcf->name.data[clcf->name.len - 1] == '/') {
+ 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 0258de5..43eb5ef 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.h
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.h
@@ -185,6 +185,12 @@
};
+typedef struct {
+ u_int connection;
+ ngx_http_proxy_ctx_t *proxy;
+} ngx_http_proxy_log_ctx_t;
+
+
#define NGX_HTTP_PROXY_PARSE_NO_HEADER 20
diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c
index 12a4c62..9d442cd 100644
--- a/src/http/modules/proxy/ngx_http_proxy_upstream.c
+++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c
@@ -210,10 +210,11 @@
{
ngx_http_proxy_ctx_t *p = data;
- ngx_chain_t *cl;
- ngx_http_request_t *r;
- ngx_output_chain_ctx_t *octx;
- ngx_chain_writer_ctx_t *wctx;
+ ngx_chain_t *cl;
+ ngx_http_request_t *r;
+ ngx_output_chain_ctx_t *octx;
+ ngx_chain_writer_ctx_t *wctx;
+ ngx_http_proxy_log_ctx_t *lctx;
r = p->request;
@@ -252,10 +253,17 @@
r->request_hunks = cl;
+ if (!(lctx = ngx_pcalloc(r->pool, sizeof(ngx_http_proxy_log_ctx_t)))) {
+ ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
+ return;
+ }
+ lctx->connection = r->connection->number;
+ lctx->proxy = p;
+
p->upstream->peer.log = r->connection->log;
p->saved_ctx = r->connection->log->data;
p->saved_handler = r->connection->log->handler;
- r->connection->log->data = p;
+ r->connection->log->data = lctx;
r->connection->log->handler = ngx_http_proxy_log_error;
p->action = "connecting to upstream";
diff --git a/src/http/ngx_http.h b/src/http/ngx_http.h
index f4f68ff..4271da3 100644
--- a/src/http/ngx_http.h
+++ b/src/http/ngx_http.h
@@ -16,9 +16,10 @@
typedef struct {
- char *action;
- char *client;
- char *url;
+ u_int connection;
+ char *action;
+ char *client;
+ char *url;
} ngx_http_log_ctx_t;
@@ -52,6 +53,7 @@
void ngx_http_finalize_request(ngx_http_request_t *r, int error);
void ngx_http_writer(ngx_event_t *wev);
+void ngx_http_empty_handler(ngx_event_t *wev);
int ngx_http_send_last(ngx_http_request_t *r);
void ngx_http_close_request(ngx_http_request_t *r, int error);
diff --git a/src/http/ngx_http_cache.c b/src/http/ngx_http_cache.c
index 8eb62eb..fd1a9d0 100644
--- a/src/http/ngx_http_cache.c
+++ b/src/http/ngx_http_cache.c
@@ -107,7 +107,7 @@
ctx->date = h->date;
ctx->length = h->length;
- if (h->key_len > (size_t) (ctx->buf->last - ctx->buf->pos)) {
+ if (h->key_len > (size_t) (ctx->buf->end - ctx->buf->pos)) {
ngx_log_error(NGX_LOG_ALERT, ctx->log, 0,
"cache file \"%s\" is probably invalid",
ctx->file.name.data);
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index f4f5d4f..e06198e 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -355,7 +355,7 @@
}
if (r->content_handler) {
- r->connection->write->event_handler = ngx_http_writer;
+ r->connection->write->event_handler = ngx_http_empty_handler;
rc = r->content_handler(r);
ngx_http_finalize_request(r, rc);
return;
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index a59b12a..62c9a66 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -21,7 +21,6 @@
static void ngx_http_keepalive_handler(ngx_event_t *ev);
static void ngx_http_set_lingering_close(ngx_http_request_t *r);
static void ngx_http_lingering_close_handler(ngx_event_t *ev);
-static void ngx_http_empty_handler(ngx_event_t *wev);
static void ngx_http_client_error(ngx_http_request_t *r,
int client_error, int error);
@@ -52,7 +51,7 @@
void ngx_http_init_connection(ngx_connection_t *c)
{
ngx_event_t *rev;
- ngx_http_log_ctx_t *lctx;
+ ngx_http_log_ctx_t *ctx;
c->addr_text.data = ngx_palloc(c->pool, c->listening->addr_text_max_len);
if (c->addr_text.data == NULL) {
@@ -68,14 +67,15 @@
return;
}
- if (!(lctx = ngx_pcalloc(c->pool, sizeof(ngx_http_log_ctx_t)))) {
+ if (!(ctx = ngx_pcalloc(c->pool, sizeof(ngx_http_log_ctx_t)))) {
ngx_http_close_connection(c);
return;
}
- lctx->client = c->addr_text.data;
- lctx->action = "reading client request line";
- c->log->data = lctx;
+ ctx->connection = c->number;
+ ctx->client = c->addr_text.data;
+ ctx->action = "reading client request line";
+ c->log->data = ctx;
c->log->handler = ngx_http_log_error;
rev = c->read;
@@ -263,7 +263,7 @@
ssize_t n;
ngx_connection_t *c;
ngx_http_request_t *r;
- ngx_http_log_ctx_t *lctx;
+ ngx_http_log_ctx_t *ctx;
ngx_http_core_srv_conf_t *cscf;
c = rev->data;
@@ -414,9 +414,9 @@
return;
}
- lctx = c->log->data;
- lctx->action = "reading client request headers";
- lctx->url = r->unparsed_uri.data;
+ ctx = c->log->data;
+ ctx->action = "reading client request headers";
+ ctx->url = r->unparsed_uri.data;
/* TODO: ngx_init_table */
r->headers_in.headers = ngx_create_table(r->pool, 20);
@@ -874,6 +874,8 @@
ngx_http_request_t *r;
ngx_http_core_loc_conf_t *clcf;
+ ngx_log_debug(wev->log, "http writer handler");
+
c = wev->data;
r = c->data;
@@ -1138,7 +1140,7 @@
{
ssize_t n;
ngx_connection_t *c;
- ngx_http_log_ctx_t *lctx;
+ ngx_http_log_ctx_t *ctx;
c = (ngx_connection_t *) rev->data;
@@ -1168,19 +1170,19 @@
return;
}
- lctx = (ngx_http_log_ctx_t *) rev->log->data;
+ ctx = (ngx_http_log_ctx_t *) rev->log->data;
rev->log->handler = NULL;
if (n == 0) {
ngx_log_error(NGX_LOG_INFO, c->log, ngx_socket_errno,
- "client %s closed keepalive connection", lctx->client);
+ "client %s closed keepalive connection", ctx->client);
ngx_http_close_connection(c);
return;
}
c->buffer->last += n;
rev->log->handler = ngx_http_log_error;
- lctx->action = "reading client request line";
+ ctx->action = "reading client request line";
ngx_http_init_request(rev);
}
@@ -1306,7 +1308,7 @@
}
-static void ngx_http_empty_handler(ngx_event_t *wev)
+void ngx_http_empty_handler(ngx_event_t *wev)
{
ngx_log_debug(wev->log, "http EMPTY handler");
@@ -1442,7 +1444,7 @@
static size_t ngx_http_log_error(void *data, char *buf, size_t len)
{
- ngx_http_log_ctx_t *ctx = (ngx_http_log_ctx_t *) data;
+ ngx_http_log_ctx_t *ctx = data;
if (ctx->action && ctx->url) {
return ngx_snprintf(buf, len, " while %s, client: %s, URL: %s",