aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/proxy/ngx_http_proxy_upstream.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2005-01-18 13:03:58 +0000
committerIgor Sysoev <igor@sysoev.ru>2005-01-18 13:03:58 +0000
commit02025fd6bdfa997f521c3b26a08aeba366308e84 (patch)
tree44db6ebb4e310f97f4550b7d7d69932636764304 /src/http/modules/proxy/ngx_http_proxy_upstream.c
parent543d02a4427e1833f8f9bdb60e3ff5e9fe2eb21b (diff)
downloadnginx-02025fd6bdfa997f521c3b26a08aeba366308e84.tar.gz
nginx-02025fd6bdfa997f521c3b26a08aeba366308e84.zip
nginx-0.1.14-RELEASE importrelease-0.1.14
*) Feature: the autoconfiguration directives: --http-client-body-temp-path=PATH, --http-proxy-temp-path=PATH, and --http-fastcgi-temp-path=PATH *) Change: the directory name for the temporary files with the client request body is specified by directive client_body_temp_path, by default it is <prefix>/client_body_temp. *) Feature: the ngx_http_fastcgi_module and the directives: fastcgi_pass, fastcgi_root, fastcgi_index, fastcgi_params, fastcgi_connect_timeout, fastcgi_send_timeout, fastcgi_read_timeout, fastcgi_send_lowat, fastcgi_header_buffer_size, fastcgi_buffers, fastcgi_busy_buffers_size, fastcgi_temp_path, fastcgi_max_temp_file_size, fastcgi_temp_file_write_size, fastcgi_next_upstream, and fastcgi_x_powered_by. *) Bugfix: the "[alert] zero size buf" error; the bug had appeared in 0.1.3. *) Change: the URI must be specified after the host name in the proxy_pass directive. *) Change: the %3F symbol in the URI was considered as the argument string start. *) Feature: the unix domain sockets support in the ngx_http_proxy_module. *) Feature: the ssl_engine and ssl_ciphers directives. Thanks to Sergey Skvortsov for SSL-accelerator.
Diffstat (limited to 'src/http/modules/proxy/ngx_http_proxy_upstream.c')
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_upstream.c49
1 files changed, 9 insertions, 40 deletions
diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c
index 47d2b17df..4dfd4e6d1 100644
--- a/src/http/modules/proxy/ngx_http_proxy_upstream.c
+++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c
@@ -14,7 +14,7 @@
static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p);
-static void ngx_http_proxy_init_upstream(void *data);
+static void ngx_http_proxy_init_upstream(ngx_http_request_t *r);
static void ngx_http_proxy_reinit_upstream(ngx_http_proxy_ctx_t *p);
static void ngx_http_proxy_connect(ngx_http_proxy_ctx_t *p);
static void ngx_http_proxy_send_request(ngx_http_proxy_ctx_t *p);
@@ -53,9 +53,7 @@ static char connection_close_header[] = "Connection: close" CRLF;
int ngx_http_proxy_request_upstream(ngx_http_proxy_ctx_t *p)
{
int rc;
- ngx_temp_file_t *tf;
ngx_http_request_t *r;
- ngx_http_request_body_t *rb;
ngx_http_proxy_upstream_t *u;
r = p->request;
@@ -75,36 +73,7 @@ int ngx_http_proxy_request_upstream(ngx_http_proxy_ctx_t *p)
u->method = r->method;
- if (!(rb = ngx_pcalloc(r->pool, sizeof(ngx_http_request_body_t)))) {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
- }
- r->request_body = rb;
-
- if (r->headers_in.content_length_n <= 0) {
- ngx_http_proxy_init_upstream(p);
- return NGX_DONE;
- }
-
- if (!(tf = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t)))) {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
- }
-
- tf->file.fd = NGX_INVALID_FILE;
- tf->file.log = r->connection->log;
- tf->path = p->lcf->temp_path;
- tf->pool = r->pool;
- tf->warn = "a client request body is buffered to a temporary file";
- /* tf->persistent = 0; */
-
- rb->handler = ngx_http_proxy_init_upstream;
- rb->data = p;
- /* rb->bufs = NULL; */
- /* rb->buf = NULL; */
- /* rb->rest = 0; */
-
- rb->temp_file = tf;
-
- rc = ngx_http_read_client_request_body(r);
+ rc = ngx_http_read_client_request_body(r, ngx_http_proxy_init_upstream);
if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
return rc;
@@ -428,17 +397,16 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p)
}
-static void ngx_http_proxy_init_upstream(void *data)
+static void ngx_http_proxy_init_upstream(ngx_http_request_t *r)
{
- ngx_http_proxy_ctx_t *p = data;
ngx_chain_t *cl;
- ngx_http_request_t *r;
+ ngx_http_proxy_ctx_t *p;
ngx_output_chain_ctx_t *output;
ngx_chain_writer_ctx_t *writer;
ngx_http_proxy_log_ctx_t *ctx;
- r = p->request;
+ p = ngx_http_get_module_ctx(r, ngx_http_proxy_module);
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"http proxy init upstream, client timer: %d",
@@ -502,7 +470,7 @@ static void ngx_http_proxy_init_upstream(void *data)
output->pool = r->pool;
output->bufs.num = 1;
output->tag = (ngx_buf_tag_t) &ngx_http_proxy_module;
- output->output_filter = (ngx_output_chain_filter_pt) ngx_chain_writer;
+ output->output_filter = ngx_chain_writer;
if (!(writer = ngx_palloc(r->pool, sizeof(ngx_chain_writer_ctx_t)))) {
ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
@@ -700,7 +668,7 @@ static void ngx_http_proxy_connect(ngx_http_proxy_ctx_t *p)
}
p->state->peer =
- &p->upstream->peer.peers->peers[p->upstream->peer.cur_peer].addr_port_text;
+ &p->upstream->peer.peers->peer[p->upstream->peer.cur_peer].name;
if (rc == NGX_CONNECT_ERROR) {
ngx_http_proxy_next_upstream(p, NGX_HTTP_PROXY_FT_ERROR);
@@ -733,7 +701,7 @@ static void ngx_http_proxy_connect(ngx_http_proxy_ctx_t *p)
}
if (r->request_body->buf) {
- if (r->request_body->temp_file->file.fd != NGX_INVALID_FILE) {
+ if (r->request_body->temp_file) {
if (!(output->free = ngx_alloc_chain_link(r->pool))) {
ngx_http_proxy_finalize_request(p,
@@ -1347,6 +1315,7 @@ static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p)
}
ep->preread_bufs->buf = p->header_in;
ep->preread_bufs->next = NULL;
+ p->header_in->recycled = 1;
ep->preread_size = p->header_in->last - p->header_in->pos;