diff options
Diffstat (limited to 'src/http')
-rw-r--r-- | src/http/modules/ngx_http_gzip_filter.c | 17 | ||||
-rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.c | 256 | ||||
-rw-r--r-- | src/http/ngx_http_header_filter.c | 2 | ||||
-rw-r--r-- | src/http/ngx_http_request.c | 32 | ||||
-rw-r--r-- | src/http/ngx_http_request_body.c | 3 | ||||
-rw-r--r-- | src/http/ngx_http_write_filter.c | 16 |
6 files changed, 174 insertions, 152 deletions
diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c index 9fff90d01..5a091b475 100644 --- a/src/http/modules/ngx_http_gzip_filter.c +++ b/src/http/modules/ngx_http_gzip_filter.c @@ -190,9 +190,9 @@ static int ngx_http_gzip_header_filter(ngx_http_request_t *r) sizeof(ngx_http_gzip_ctx_t), NGX_ERROR); ctx->request = r; - if (!(r->headers_out.content_encoding = - ngx_http_add_header(&r->headers_out, ngx_http_headers_out))) - { + r->headers_out.content_encoding = + ngx_http_add_header(&r->headers_out, ngx_http_headers_out); + if (r->headers_out.content_encoding == NULL) { return NGX_ERROR; } @@ -222,9 +222,7 @@ static int ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in) ngx_http_gzip_ctx_t *ctx; ngx_http_gzip_conf_t *conf; - ctx = ngx_http_get_module_ctx(r, ngx_http_gzip_filter_module); - - if (ctx == NULL) { + if (!(ctx = ngx_http_get_module_ctx(r, ngx_http_gzip_filter_module))) { return ngx_http_next_body_filter(r, in); } @@ -344,9 +342,8 @@ static int ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in) } else if (ctx->hunks < conf->bufs.num) { ngx_test_null(ctx->out_hunk, - ngx_create_temp_hunk(r->pool, conf->bufs.size, - 0, 0), - ngx_http_gzip_error(ctx)); + ngx_create_temp_hunk(r->pool, conf->bufs.size), + ngx_http_gzip_error(ctx)); ctx->out_hunk->tag = (ngx_hunk_tag_t) &ngx_http_gzip_filter_module; ctx->out_hunk->type |= NGX_HUNK_RECYCLED; @@ -429,7 +426,7 @@ ngx_log_debug(r->connection->log, "DEFLATE(): %08x %08x %d %d %d" _ } else { ngx_test_null(h, - ngx_create_temp_hunk(r->pool, 8, 0, 0), + ngx_create_temp_hunk(r->pool, 8), ngx_http_gzip_error(ctx)); h->type |= NGX_HUNK_LAST; diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c index c9caaa79a..053b7b598 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.c +++ b/src/http/modules/proxy/ngx_http_proxy_handler.c @@ -38,86 +38,101 @@ static char *ngx_http_proxy_parse_upstream(ngx_str_t *url, ngx_http_proxy_upstream_t *u); -static ngx_command_t ngx_http_proxy_commands[] = { - - {ngx_string("proxy_pass"), - NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, - ngx_http_proxy_set_pass, - NGX_HTTP_LOC_CONF_OFFSET, - 0, - NULL}, - - {ngx_string("proxy_request_buffer_size"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, - ngx_conf_set_size_slot, - NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_proxy_loc_conf_t, request_buffer_size), - NULL}, - - {ngx_string("proxy_connect_timeout"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, - ngx_conf_set_msec_slot, - NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_proxy_loc_conf_t, connect_timeout), - NULL}, - - {ngx_string("proxy_send_timeout"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, - ngx_conf_set_msec_slot, - NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_proxy_loc_conf_t, send_timeout), - NULL}, - - {ngx_string("proxy_header_buffer_size"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, - ngx_conf_set_size_slot, - NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_proxy_loc_conf_t, header_buffer_size), - NULL}, - - {ngx_string("proxy_read_timeout"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, - ngx_conf_set_msec_slot, - NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_proxy_loc_conf_t, read_timeout), - NULL}, - - {ngx_string("proxy_buffers"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, - ngx_conf_set_bufs_slot, - NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_proxy_loc_conf_t, bufs), - NULL}, - - {ngx_string("proxy_busy_buffers_size"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, - ngx_conf_set_size_slot, - NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_proxy_loc_conf_t, busy_buffers_size), - NULL}, - - {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_string("proxy_temp_file_write_size"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, - ngx_conf_set_size_slot, - NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_proxy_loc_conf_t, temp_file_write_size), - NULL}, - - {ngx_string("proxy_pass_server"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, - ngx_conf_set_flag_slot, - NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_proxy_loc_conf_t, pass_server), - NULL}, - - ngx_null_command +static ngx_conf_bitmask_t next_upstream_masks[] = { + { ngx_string("error"), NGX_HTTP_PROXY_FT_ERROR }, + { ngx_string("timeout"), NGX_HTTP_PROXY_FT_TIMEOUT }, + { ngx_string("http_header"), NGX_HTTP_PROXY_FT_HTTP_HEADER }, + { ngx_string("http_500"), NGX_HTTP_PROXY_FT_HTTP_500 }, + { ngx_null_string, 0 } +}; + +static ngx_command_t ngx_http_proxy_commands[] = { + + { ngx_string("proxy_pass"), + NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_http_proxy_set_pass, + NGX_HTTP_LOC_CONF_OFFSET, + 0, + NULL }, + + { ngx_string("proxy_request_buffer_size"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_size_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_proxy_loc_conf_t, request_buffer_size), + NULL }, + + { ngx_string("proxy_connect_timeout"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_msec_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_proxy_loc_conf_t, connect_timeout), + NULL }, + + { ngx_string("proxy_send_timeout"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_msec_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_proxy_loc_conf_t, send_timeout), + NULL }, + + { ngx_string("proxy_header_buffer_size"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_size_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_proxy_loc_conf_t, header_buffer_size), + NULL }, + + { ngx_string("proxy_read_timeout"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_msec_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_proxy_loc_conf_t, read_timeout), + NULL }, + + { ngx_string("proxy_buffers"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, + ngx_conf_set_bufs_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_proxy_loc_conf_t, bufs), + NULL }, + + { ngx_string("proxy_busy_buffers_size"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_size_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_proxy_loc_conf_t, busy_buffers_size), + NULL }, + + { 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_string("proxy_temp_file_write_size"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_size_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_proxy_loc_conf_t, temp_file_write_size), + NULL }, + + { ngx_string("proxy_pass_server"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, + ngx_conf_set_flag_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_proxy_loc_conf_t, pass_server), + NULL }, + + { ngx_string("proxy_next_upstream"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_ANY, + ngx_conf_set_bitmask_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_proxy_loc_conf_t, next_upstream), + &next_upstream_masks }, + + ngx_null_command }; @@ -231,8 +246,8 @@ static void ngx_http_proxy_init_request(void *data) ngx_chain_t *cl; ngx_http_request_t *r; - ngx_output_chain_ctx_t *out_ctx; - ngx_chain_write_ctx_t *write_ctx; + ngx_output_chain_ctx_t *octx; + ngx_chain_writer_ctx_t *wctx; r = p->request; @@ -262,38 +277,38 @@ ngx_log_debug(r->connection->log, "timer_set: %d" _ r->connection->log->handler = ngx_http_proxy_log_error; p->action = "connecting to upstream"; - out_ctx = ngx_pcalloc(r->pool, sizeof(ngx_output_chain_ctx_t)); - if (out_ctx == NULL) { + octx = ngx_pcalloc(r->pool, sizeof(ngx_output_chain_ctx_t)); + if (octx == NULL) { ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR); return; } - p->output_chain_ctx = out_ctx; + p->output_chain_ctx = octx; if (r->request_body_hunk) { - out_ctx->free = ngx_alloc_chain_link(r->pool); - if (out_ctx->free == NULL) { + octx->free = ngx_alloc_chain_link(r->pool); + if (octx->free == NULL) { ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR); } - out_ctx->free->hunk = r->request_body_hunk; - out_ctx->free->next = NULL; + octx->free->hunk = r->request_body_hunk; + octx->free->next = NULL; } - out_ctx->sendfile = r->sendfile; - out_ctx->pool = r->pool; - out_ctx->bufs.num = 1; - out_ctx->tag = (ngx_hunk_tag_t) &ngx_http_proxy_module; - out_ctx->output_filter = (ngx_output_chain_filter_pt) ngx_chain_write; + octx->sendfile = r->sendfile; + octx->pool = r->pool; + octx->bufs.num = 1; + octx->tag = (ngx_hunk_tag_t) &ngx_http_proxy_module; + octx->output_filter = (ngx_output_chain_filter_pt) ngx_chain_writer; - write_ctx = ngx_pcalloc(r->pool, sizeof(ngx_chain_write_ctx_t)); - if (write_ctx == NULL) { + wctx = ngx_pcalloc(r->pool, sizeof(ngx_chain_writer_ctx_t)); + if (wctx == NULL) { ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR); return; } - out_ctx->output_ctx = write_ctx; - write_ctx->pool = r->pool; - write_ctx->last = &write_ctx->out; + octx->output_ctx = wctx; + wctx->pool = r->pool; + wctx->last = &wctx->out; ngx_http_proxy_send_request(p); } @@ -339,7 +354,7 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p) /* STUB */ len++; - ngx_test_null(h, ngx_create_temp_hunk(r->pool, len, 0, 0), NULL); + ngx_test_null(h, ngx_create_temp_hunk(r->pool, len), NULL); ngx_alloc_link_and_set_hunk(chain, h, r->pool, NULL); @@ -439,7 +454,7 @@ static void ngx_http_proxy_send_request(ngx_http_proxy_ctx_t *p) int rc; ngx_chain_t *cl; ngx_connection_t *c; - ngx_chain_write_ctx_t *ctx; + ngx_chain_writer_ctx_t *wctx; c = p->upstream.connection; @@ -447,8 +462,8 @@ static void ngx_http_proxy_send_request(ngx_http_proxy_ctx_t *p) if (c) { p->action = "sending request to upstream"; - ctx = p->output_chain_ctx->output_ctx; - ctx->connection = c; + wctx = p->output_chain_ctx->output_ctx; + wctx->connection = c; rc = ngx_output_chain(p->output_chain_ctx, !p->request_sent ? p->request->request_hunks: NULL); @@ -504,6 +519,20 @@ static void ngx_http_proxy_send_request(ngx_http_proxy_ctx_t *p) ngx_event_connect_peer_failed(&p->upstream); ngx_http_proxy_close_connection(c); + + if (p->upstream.tries == 0 + || !(p->lcf->next_upstream & NGX_HTTP_PROXY_FT_ERROR)) + { + ngx_http_proxy_finalize_request(p, + p->timedout ? NGX_HTTP_GATEWAY_TIME_OUT: + NGX_HTTP_BAD_GATEWAY); + return; + } + + if (!p->fatal_error) { + ngx_http_proxy_send_request(p); + return; + } } for ( ;; ) { @@ -586,8 +615,7 @@ static void ngx_http_proxy_process_upstream_status_line(ngx_event_t *rev) if (p->header_in == NULL) { p->header_in = ngx_create_temp_hunk(p->request->pool, - p->lcf->header_buffer_size, - 0, 0); + p->lcf->header_buffer_size); if (p->header_in == NULL) { ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR); return; @@ -746,8 +774,8 @@ static void ngx_http_proxy_process_upstream_headers(ngx_event_t *rev) } } - ngx_log_debug(c->log, "HTTP proxy header: %08X '%s: %s'" _ - h _ h->key.data _ h->value.data); + ngx_log_debug(c->log, "HTTP proxy header: '%s: %s'" _ + h->key.data _ h->value.data); continue; @@ -952,6 +980,12 @@ static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p) ep->preread_size = p->header_in->last - p->header_in->pos; + if (ngx_event_flags & NGX_USE_AIO_EVENT) { + + /* the posted aio operation can currupt shadow buf */ + ep->single_buf = 1; + } + /* * event_pipe would do p->header_in->last += ep->preread_size * as though these bytes were read. @@ -1405,6 +1439,8 @@ static void *ngx_http_proxy_create_loc_conf(ngx_conf_t *cf) conf->path = NULL; + conf->next_upstream = 0; + conf->upstreams = NULL; conf->peers = NULL; @@ -1428,8 +1464,6 @@ static void *ngx_http_proxy_create_loc_conf(ngx_conf_t *cf) /* "proxy_cyclic_temp_file" is disabled */ conf->cyclic_temp_file = 0; - conf->next_upstream = NGX_CONF_UNSET; - conf->pass_server = NGX_CONF_UNSET; return conf; @@ -1464,8 +1498,8 @@ static char *ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, ngx_conf_merge_size_value(conf->temp_file_write_size, prev->temp_file_write_size, 16384); - ngx_conf_merge_value(conf->next_upstream, prev->next_upstream, - (NGX_HTTP_PROXY_FT_ERROR|NGX_HTTP_PROXY_FT_TIMEOUT)); + ngx_conf_merge_bitmask_value(conf->next_upstream, prev->next_upstream, + (NGX_HTTP_PROXY_FT_ERROR|NGX_HTTP_PROXY_FT_TIMEOUT)); ngx_conf_merge_path_value(conf->temp_path, prev->temp_path, "temp", 1, 2, 0, cf->pool); diff --git a/src/http/ngx_http_header_filter.c b/src/http/ngx_http_header_filter.c index fe97d2958..f85bd4575 100644 --- a/src/http/ngx_http_header_filter.c +++ b/src/http/ngx_http_header_filter.c @@ -210,7 +210,7 @@ static int ngx_http_header_filter(ngx_http_request_t *r) len += header[i].key.len + 2 + header[i].value.len + 2; } - ngx_test_null(h, ngx_create_temp_hunk(r->pool, len, 0, 0), NGX_ERROR); + ngx_test_null(h, ngx_create_temp_hunk(r->pool, len), NGX_ERROR); /* "HTTP/1.x " */ h->last = ngx_cpymem(h->last, "HTTP/1.1 ", sizeof("HTTP/1.x ") - 1); diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index be38358e0..36fac0352 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -68,8 +68,7 @@ void ngx_http_init_connection(ngx_connection_t *c) return; } - lctx = ngx_pcalloc(c->pool, sizeof(ngx_http_log_ctx_t)); - if (lctx == NULL) { + if (!(lctx = ngx_pcalloc(c->pool, sizeof(ngx_http_log_ctx_t)))) { ngx_http_close_connection(c); return; } @@ -133,8 +132,7 @@ static void ngx_http_init_request(ngx_event_t *rev) ngx_memzero(r, sizeof(ngx_http_request_t)); } else { - r = ngx_pcalloc(c->pool, sizeof(ngx_http_request_t)); - if (r == NULL) { + if (!(r = ngx_pcalloc(c->pool, sizeof(ngx_http_request_t)))) { ngx_http_close_connection(c); return; } @@ -212,23 +210,20 @@ ngx_log_debug(rev->log, "IN: %08x" _ in_port); c->log->log_level = clcf->err_log->log_level; if (c->buffer == NULL) { - c->buffer = ngx_create_temp_hunk(c->pool, - cscf->client_header_buffer_size, - 0, 0); + c->buffer = + ngx_create_temp_hunk(c->pool, cscf->client_header_buffer_size); if (c->buffer == NULL) { ngx_http_close_connection(c); return; } } - r->pool = ngx_create_pool(cscf->request_pool_size, c->log); - if (r->pool == NULL) { + if (!(r->pool = ngx_create_pool(cscf->request_pool_size, c->log))) { ngx_http_close_connection(c); return; } - r->headers_out.headers = ngx_create_table(r->pool, 20); - if (r->headers_out.headers == NULL) { + if (!(r->headers_out.headers = ngx_create_table(r->pool, 20))) { ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); ngx_http_close_connection(c); return; @@ -290,7 +285,7 @@ static void ngx_http_process_request_line(ngx_event_t *rev) /* the request line has been parsed successfully */ - /* STUB: we need to handle such URIs */ + /* TODO: we need to handle such URIs */ if (r->complex_uri || r->unusual_uri) { r->request_line.len = r->request_end - r->request_start; r->request_line.data = r->request_start; @@ -323,8 +318,7 @@ static void ngx_http_process_request_line(ngx_event_t *rev) r->uri.len = r->uri_end - r->uri_start; } - r->uri.data = ngx_palloc(r->pool, r->uri.len + 1); - if (r->uri.data == NULL) { + if (!(r->uri.data = ngx_palloc(r->pool, r->uri.len + 1))) { ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); ngx_http_close_connection(c); return; @@ -378,8 +372,7 @@ static void ngx_http_process_request_line(ngx_event_t *rev) r->exten.len = r->uri_end - r->uri_ext; } - r->exten.data = ngx_palloc(r->pool, r->exten.len + 1); - if (r->exten.data == NULL) { + if (!(r->exten.data = ngx_palloc(r->pool, r->exten.len + 1))) { ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); ngx_http_close_connection(c); return; @@ -393,8 +386,7 @@ static void ngx_http_process_request_line(ngx_event_t *rev) if (r->args_start && r->uri_end > r->args_start) { r->args.len = r->uri_end - r->args_start; - r->args.data = ngx_palloc(r->pool, r->args.len + 1); - if (r->args.data == NULL) { + if (!(r->args.data = ngx_palloc(r->pool, r->args.len + 1))) { ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); ngx_http_close_connection(c); return; @@ -531,8 +523,8 @@ static void ngx_http_process_request_headers(ngx_event_t *rev) /* a header line has been parsed successfully */ - if (!(h = ngx_http_add_header(&r->headers_in, ngx_http_headers_in))) - { + h = ngx_http_add_header(&r->headers_in, ngx_http_headers_in); + if (h == NULL) { ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); ngx_http_close_connection(c); return; diff --git a/src/http/ngx_http_request_body.c b/src/http/ngx_http_request_body.c index 19730e7b3..eb82af05c 100644 --- a/src/http/ngx_http_request_body.c +++ b/src/http/ngx_http_request_body.c @@ -47,8 +47,7 @@ int ngx_http_read_client_request_body(ngx_http_request_t *r, size = request_buffer_size; } - ngx_test_null(r->request_body_hunk, - ngx_create_temp_hunk(r->pool, size, 0, 0), + ngx_test_null(r->request_body_hunk, ngx_create_temp_hunk(r->pool, size), NGX_HTTP_INTERNAL_SERVER_ERROR); r->connection->read->event_handler = diff --git a/src/http/ngx_http_write_filter.c b/src/http/ngx_http_write_filter.c index b7cb16c3f..143f38c7d 100644 --- a/src/http/ngx_http_write_filter.c +++ b/src/http/ngx_http_write_filter.c @@ -21,16 +21,16 @@ static char *ngx_http_write_filter_merge_conf(ngx_conf_t *cf, static int ngx_http_write_filter_init(ngx_cycle_t *cycle); -static ngx_command_t ngx_http_write_filter_commands[] = { +static ngx_command_t ngx_http_write_filter_commands[] = { - {ngx_string("buffer_output"), - NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, - ngx_conf_set_size_slot, - NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_write_filter_conf_t, buffer_output), - NULL}, + { ngx_string("buffer_output"), + NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_size_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_write_filter_conf_t, buffer_output), + NULL }, - ngx_null_command + ngx_null_command }; |