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_gzip_filter.c27
-rw-r--r--src/http/modules/ngx_http_index_handler.c3
-rw-r--r--src/http/modules/ngx_http_not_modified_filter.c4
-rw-r--r--src/http/modules/ngx_http_static_handler.c3
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_cache.c26
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_handler.c30
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_upstream.c72
7 files changed, 90 insertions, 75 deletions
diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c
index fae9c9edb..34d872ca5 100644
--- a/src/http/modules/ngx_http_gzip_filter.c
+++ b/src/http/modules/ngx_http_gzip_filter.c
@@ -377,9 +377,11 @@ static int ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
ctx->zstream.avail_out = conf->bufs.size;
}
-ngx_log_debug(r->connection->log, "deflate(): %08x %08x %d %d %d" _
- ctx->zstream.next_in _ ctx->zstream.next_out _
- ctx->zstream.avail_in _ ctx->zstream.avail_out _ ctx->flush);
+ ngx_log_debug5(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "deflate in: ni:%X no:%X ai:%d ao:%d fl:%d",
+ ctx->zstream.next_in, ctx->zstream.next_out,
+ ctx->zstream.avail_in, ctx->zstream.avail_out,
+ ctx->flush);
rc = deflate(&ctx->zstream, ctx->flush);
if (rc != Z_OK && rc != Z_STREAM_END) {
@@ -388,9 +390,11 @@ ngx_log_debug(r->connection->log, "deflate(): %08x %08x %d %d %d" _
return ngx_http_gzip_error(ctx);
}
-ngx_log_debug(r->connection->log, "DEFLATE(): %08x %08x %d %d %d" _
- ctx->zstream.next_in _ ctx->zstream.next_out _
- ctx->zstream.avail_in _ ctx->zstream.avail_out _ rc);
+ ngx_log_debug5(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "deflate out: ni:%X no:%X ai:%d ao:%d rc:%d",
+ ctx->zstream.next_in, ctx->zstream.next_out,
+ ctx->zstream.avail_in, ctx->zstream.avail_out,
+ rc);
ctx->in_hunk->pos = (char *) ctx->zstream.next_in;
ctx->out_hunk->last = (char *) ctx->zstream.next_out;
@@ -512,7 +516,6 @@ static void *ngx_http_gzip_filter_alloc(void *opaque, u_int items, u_int size)
int alloc;
void *p;
-
alloc = items * size;
if (alloc % 512 != 0) {
@@ -527,10 +530,9 @@ static void *ngx_http_gzip_filter_alloc(void *opaque, u_int items, u_int size)
ctx->free_mem += alloc;
ctx->allocated -= alloc;
-#if 1
- ngx_log_debug(ctx->request->connection->log, "ALLOC: %d:%d:%d:%08X" _
- items _ size _ alloc _ p);
-#endif
+ ngx_log_debug4(NGX_LOG_DEBUG_HTTP, ctx->request->connection->log, 0,
+ "gzip alloc: n:%d s:%d a:%d p:%08X",
+ items, size, alloc, p);
return p;
}
@@ -550,7 +552,8 @@ static void ngx_http_gzip_filter_free(void *opaque, void *address)
ngx_http_gzip_ctx_t *ctx = opaque;
#if 0
- ngx_log_debug(ctx->request->connection->log, "FREE: %08X" _ address);
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->request->connection->log, 0,
+ "gzip free: %X", address);
#endif
}
diff --git a/src/http/modules/ngx_http_index_handler.c b/src/http/modules/ngx_http_index_handler.c
index edcf54a2d..029843e70 100644
--- a/src/http/modules/ngx_http_index_handler.c
+++ b/src/http/modules/ngx_http_index_handler.c
@@ -286,7 +286,8 @@ static ngx_int_t ngx_http_index_test_dir(ngx_http_request_t *r,
ctx->path.data[ctx->path.len - 1] = '\0';
ctx->path.data[ctx->path.len] = '\0';
-ngx_log_debug(r->connection->log, "IS_DIR: %s" _ ctx->path.data);
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http check dir: \"%s\"", ctx->path.data);
if (ngx_file_info(ctx->path.data, &r->file.info) == -1) {
diff --git a/src/http/modules/ngx_http_not_modified_filter.c b/src/http/modules/ngx_http_not_modified_filter.c
index 11cc21cb9..e1a961f1f 100644
--- a/src/http/modules/ngx_http_not_modified_filter.c
+++ b/src/http/modules/ngx_http_not_modified_filter.c
@@ -49,8 +49,8 @@ static int ngx_http_not_modified_header_filter(ngx_http_request_t *r)
ims = ngx_http_parse_time(r->headers_in.if_modified_since->value.data,
r->headers_in.if_modified_since->value.len);
- ngx_log_debug(r->connection->log, "%d %d" _
- ims _ r->headers_out.last_modified_time);
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http ims:%d lm:%d", ims, r->headers_out.last_modified_time);
/*
* I think that the equality of the dates is correcter
diff --git a/src/http/modules/ngx_http_static_handler.c b/src/http/modules/ngx_http_static_handler.c
index 617bb4d80..699747123 100644
--- a/src/http/modules/ngx_http_static_handler.c
+++ b/src/http/modules/ngx_http_static_handler.c
@@ -59,7 +59,8 @@ static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r)
char *last;
uint32_t file_crc, redirect_crc;
ngx_fd_t fd;
- ngx_int_t rc, level;
+ ngx_int_t rc;
+ ngx_uint_t level;
ngx_str_t name, location;
ngx_err_t err;
ngx_log_t *log;
diff --git a/src/http/modules/proxy/ngx_http_proxy_cache.c b/src/http/modules/proxy/ngx_http_proxy_cache.c
index 9661cff96..ce2226d41 100644
--- a/src/http/modules/proxy/ngx_http_proxy_cache.c
+++ b/src/http/modules/proxy/ngx_http_proxy_cache.c
@@ -167,8 +167,9 @@ static int ngx_http_proxy_process_cached_header(ngx_http_proxy_ctx_t *p)
ngx_cpystrn(c->status_line.data, p->status_start, c->status_line.len + 1);
- ngx_log_debug(r->connection->log, "http cache status %d '%s'" _
- c->status _ c->status_line.data);
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http cache status %d \"%s\"",
+ c->status, c->status_line.data);
/* TODO: ngx_init_table */
c->headers_in.headers = ngx_create_table(r->pool, 20);
@@ -212,8 +213,9 @@ static int ngx_http_proxy_process_cached_header(ngx_http_proxy_ctx_t *p)
}
}
- ngx_log_debug(r->connection->log, "HTTP cache header: '%s: %s'" _
- h->key.data _ h->value.data);
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http cache header: \"%s: %s\"",
+ h->key.data, h->value.data);
continue;
@@ -221,7 +223,8 @@ static int ngx_http_proxy_process_cached_header(ngx_http_proxy_ctx_t *p)
/* a whole header has been parsed successfully */
- ngx_log_debug(r->connection->log, "HTTP header done");
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http cache header done");
c->ctx.file_start = p->header_in->pos - p->header_in->start;
@@ -253,7 +256,8 @@ void ngx_http_proxy_cache_busy_lock(ngx_http_proxy_ctx_t *p)
rc = ngx_http_busy_lock_cachable(p->lcf->busy_lock, &p->busy_lock,
p->try_busy_lock);
-ngx_log_debug(p->request->connection->log, "LOCK CACHABLE: %d" _ rc);
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, p->request->connection->log, 0,
+ "http cache busy lock cachable: %d", rc);
if (rc == NGX_OK) {
if (p->try_busy_lock) {
@@ -354,8 +358,9 @@ static void ngx_http_proxy_cache_look_complete_request(ngx_http_proxy_ctx_t *p)
return;
}
-ngx_log_debug(p->request->connection->log, "OLD: %d, NEW: %d" _
- p->cache->ctx.file.fd _ ctx->file.fd);
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, p->request->connection->log, 0,
+ "http cache old fd:%d, new fd:%d",
+ p->cache->ctx.file.fd, ctx->file.fd);
if (p->cache->ctx.file.fd != NGX_INVALID_FILE) {
if (ngx_close_file(p->cache->ctx.file.fd) == NGX_FILE_ERROR) {
@@ -603,8 +608,9 @@ int ngx_http_proxy_update_cache(ngx_http_proxy_ctx_t *p)
ep = p->upstream->event_pipe;
-ngx_log_debug(p->request->connection->log, "LEN: " OFF_T_FMT ", " OFF_T_FMT _
- p->cache->ctx.length _ ep->read_length);
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, p->request->connection->log, 0,
+ "http cache update len: " OFF_T_FMT ":" OFF_T_FMT,
+ p->cache->ctx.length, ep->read_length);
if (p->cache->ctx.length == -1) {
/* TODO: test rc */
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c
index 84396a948..59b1c06e8 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.c
@@ -346,7 +346,7 @@ void ngx_http_proxy_check_broken_connection(ngx_event_t *wev)
ngx_http_request_t *r;
ngx_http_proxy_ctx_t *p;
- ngx_log_debug(wev->log, "http proxy check client");
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0, "http proxy check client");
c = wev->data;
r = c->data;
@@ -362,14 +362,16 @@ void ngx_http_proxy_check_broken_connection(ngx_event_t *wev)
if (!p->cachable && p->upstream->peer.connection) {
ngx_log_error(NGX_LOG_INFO, wev->log, wev->kq_errno,
- "client closed prematurely connection, "
+ "kevent() reported that client have closed "
+ "prematurely connection, "
"so upstream connection is closed too");
ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST);
return;
}
ngx_log_error(NGX_LOG_INFO, wev->log, wev->kq_errno,
- "client closed prematurely connection");
+ "kevent() reported that client have closed "
+ "prematurely connection");
if (p->upstream == NULL || p->upstream->peer.connection == NULL) {
ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST);
@@ -385,7 +387,7 @@ void ngx_http_proxy_busy_lock_handler(ngx_event_t *rev)
ngx_http_request_t *r;
ngx_http_proxy_ctx_t *p;
- ngx_log_debug(rev->log, "busy lock");
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0, "http proxy busy lock");
c = rev->data;
r = c->data;
@@ -412,11 +414,12 @@ void ngx_http_proxy_busy_lock_handler(ngx_event_t *rev)
return;
}
- ngx_log_debug(rev->log, "client sent while busy lock");
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0,
+ "http proxy: client sent while busy lock");
/*
* TODO: kevent() notify about error, otherwise we need to
- * call ngx_peek(): recv(MSG_PEEK) to get errno. THINK about aio
+ * call ngx_peek(): recv(MSG_PEEK) to get errno. THINK about aio.
* if there's no error we need to disable event.
*/
@@ -452,7 +455,8 @@ void ngx_http_proxy_finalize_request(ngx_http_proxy_ctx_t *p, int rc)
r = p->request;
- ngx_log_debug(r->connection->log, "finalize http proxy request");
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "finalize http proxy request");
if (p->upstream && p->upstream->peer.connection) {
ngx_http_proxy_close_connection(p);
@@ -470,12 +474,15 @@ void ngx_http_proxy_finalize_request(ngx_http_proxy_ctx_t *p, int rc)
}
if (p->upstream && p->upstream->event_pipe) {
-ngx_log_debug(r->connection->log, "TEMP FD: %d" _
- p->upstream->event_pipe->temp_file->file.fd);
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http proxy temp fd: %d",
+ p->upstream->event_pipe->temp_file->file.fd);
}
if (p->cache) {
-ngx_log_debug(r->connection->log, "CACHE FD: %d" _ p->cache->ctx.file.fd);
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http proxy cache fd: %d",
+ p->cache->ctx.file.fd);
}
if (p->upstream && p->upstream->event_pipe) {
@@ -504,7 +511,8 @@ void ngx_http_proxy_close_connection(ngx_http_proxy_ctx_t *p)
p->lcf->busy_lock->busy--;
}
- ngx_log_debug(c->log, "proxy close connection: %d" _ c->fd);
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
+ "http proxy close connection: %d", c->fd);
if (c->fd == -1) {
#if 0
diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c
index d36cbee10..a65b86470 100644
--- a/src/http/modules/proxy/ngx_http_proxy_upstream.c
+++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c
@@ -192,15 +192,19 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p)
*(h->last++) = CR; *(h->last++) = LF;
- ngx_log_debug(r->connection->log, "proxy: '%s: %s'" _
- header[i].key.data _ header[i].value.data);
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http proxy header: \"%s: %s\"",
+ header[i].key.data, header[i].value.data);
}
/* add "\r\n" at the header end */
*(h->last++) = CR; *(h->last++) = LF;
- /* STUB */ *(h->last) = '\0';
- ngx_log_debug(r->connection->log, "PROXY:\n'%s'" _ h->pos);
+#if (NGX_DEBUG)
+ *(h->last) = '\0';
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http proxy header:\n\"%s\"", h->pos);
+#endif
return chain;
}
@@ -218,8 +222,9 @@ static void ngx_http_proxy_init_upstream(void *data)
r = p->request;
-ngx_log_debug(r->connection->log, "timer_set: %d" _
- r->connection->read->timer_set);
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http proxy set timer: %d",
+ r->connection->read->timer_set);
if (r->connection->read->timer_set) {
ngx_del_timer(r->connection->read);
@@ -588,7 +593,7 @@ static void ngx_http_proxy_send_request_handler(ngx_event_t *wev)
static void ngx_http_proxy_dummy_handler(ngx_event_t *wev)
{
- ngx_log_debug(wev->log, "dummy handler");
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0, "http proxy dummy handler");
}
@@ -603,7 +608,8 @@ static void ngx_http_proxy_process_upstream_status_line(ngx_event_t *rev)
p = c->data;
p->action = "reading upstream status line";
- ngx_log_debug(rev->log, "http proxy process status line");
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0,
+ "http proxy process status line");
if (rev->timedout) {
ngx_http_proxy_next_upstream(p, NGX_HTTP_PROXY_FT_TIMEOUT);
@@ -717,8 +723,9 @@ static void ngx_http_proxy_process_upstream_status_line(ngx_event_t *rev)
ngx_cpystrn(p->upstream->status_line.data, p->status_start,
p->upstream->status_line.len + 1);
- ngx_log_debug(rev->log, "http proxy status %d '%s'" _
- p->upstream->status _ p->upstream->status_line.data);
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, rev->log, 0,
+ "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;
@@ -747,7 +754,8 @@ static void ngx_http_proxy_process_upstream_headers(ngx_event_t *rev)
r = p->request;
p->action = "reading upstream headers";
- ngx_log_debug(rev->log, "http proxy process header line");
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0,
+ "http proxy process header line");
if (rev->timedout) {
ngx_http_proxy_next_upstream(p, NGX_HTTP_PROXY_FT_TIMEOUT);
@@ -818,8 +826,9 @@ 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_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
+ "http proxy header: \"%s: %s\"",
+ h->key.data, h->value.data);
continue;
@@ -827,7 +836,8 @@ static void ngx_http_proxy_process_upstream_headers(ngx_event_t *rev)
/* a whole header has been parsed successfully */
- ngx_log_debug(c->log, "HTTP header done");
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
+ "http proxy header done");
/* TODO: hook to process the upstream header */
@@ -1072,13 +1082,15 @@ static void ngx_http_proxy_process_body(ngx_event_t *ev)
c = ev->data;
if (ev->write) {
- ngx_log_debug(ev->log, "http proxy process downstream");
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0,
+ "http proxy process downstream");
r = c->data;
p = ngx_http_get_module_ctx(r, ngx_http_proxy_module);
p->action = "sending to client";
} else {
- ngx_log_debug(ev->log, "http proxy process upstream");
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0,
+ "http proxy process upstream");
p = c->data;
r = p->request;
p->action = "reading upstream body";
@@ -1125,7 +1137,8 @@ static void ngx_http_proxy_process_body(ngx_event_t *ev)
}
if (ep->upstream_done || ep->upstream_eof || ep->upstream_error) {
- ngx_log_debug(ev->log, "http proxy upstream exit");
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0,
+ "http proxy upstream exit");
ngx_http_busy_unlock(p->lcf->busy_lock, &p->busy_lock);
ngx_http_proxy_finalize_request(p, 0);
return;
@@ -1133,30 +1146,12 @@ static void ngx_http_proxy_process_body(ngx_event_t *ev)
}
if (ep->downstream_error) {
- ngx_log_debug(ev->log, "http proxy downstream error");
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0,
+ "http proxy downstream error");
if (!p->cachable && p->upstream->peer.connection) {
ngx_http_proxy_finalize_request(p, 0);
}
}
-
-#if 0
- if (ep->downstream_done) {
- ngx_log_debug(ev->log, "http proxy downstream done");
- ngx_http_proxy_finalize_request(p, 0);
- return;
- }
-
- if (ep->downstream_error) {
- ngx_log_debug(ev->log, "http proxy downstream error");
- if (!p->cachable && p->upstream->peer.connection) {
- ngx_http_proxy_close_connection(p);
- }
-
- if (p->upstream->peer.connection == NULL) {
- ngx_http_close_request(r);
- }
- }
-#endif
}
@@ -1164,7 +1159,8 @@ static void ngx_http_proxy_next_upstream(ngx_http_proxy_ctx_t *p, int ft_type)
{
int status;
-ngx_log_debug(p->request->connection->log, "next upstream: %d" _ ft_type);
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, p->request->connection->log, 0,
+ "http proxy next upstream: %d", ft_type);
ngx_http_busy_unlock(p->lcf->busy_lock, &p->busy_lock);