Mercurial > hg > nginx
diff src/http/modules/proxy/ngx_http_proxy_handler.c @ 168:ba5dbb949603
nginx-0.0.1-2003-10-31-10:10:36 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 31 Oct 2003 07:10:36 +0000 |
parents | 389d7ee9fa60 |
children | edf29bb717da |
line wrap: on
line diff
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c +++ b/src/http/modules/proxy/ngx_http_proxy_handler.c @@ -229,6 +229,7 @@ static int ngx_http_proxy_handler(ngx_ht r->request_body_handler = ngx_http_proxy_init_request; r->data = p; + /* TODO: we ignore return value of ngx_http_read_client_request_body */ ngx_http_read_client_request_body(r, p->lcf->request_buffer_size); return NGX_DONE; @@ -449,6 +450,87 @@ static void ngx_http_proxy_send_request_ } +#if 0 + +static int ngx_http_proxy_connect(ngx_http_proxy_ctx_t *p) +{ + int rc; + ngx_chain_t *cl; + ngx_connection_t *c; + + for ( ;; ) { + p->action = "connecting to upstream"; + + rc = ngx_event_connect_peer(&p->upstream); + + if (rc == NGX_ERROR) { + ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR); + return NGX_DONE; + } + + if (rc == NGX_CONNECT_ERROR) { + ngx_event_connect_peer_failed(&p->upstream); + +#if 0 + /* TODO: make separate func and call it from next_upstream */ + + if (!(state = ngx_push_array(p->states))) { + ngx_http_proxy_finalize_request(p, + NGX_HTTP_INTERNAL_SERVER_ERROR); + return NGX_DONE; + } + + state->status = NGX_HTTP_BAD_GATEWAY; + state->peer = + p->upstream.peers->peers[p->upstream.cur_peer].addr_port_text; + +#endif + + if (p->upstream.tries == 0) { + ngx_http_proxy_finalize_request(p, NGX_HTTP_BAD_GATEWAY); + return NGX_DONE; + } + + continue; + } + + p->upstream.connection->data = p; + p->upstream.connection->write->event_handler = + ngx_http_proxy_send_request_handler; + p->upstream.connection->read->event_handler = + ngx_http_proxy_process_upstream_status_line; + + c = p->upstream.connection; + c->pool = p->request->pool; + c->read->log = c->write->log = c->log = p->request->connection->log; + + if (p->upstream.tries > 1 && p->request_sent) { + + /* reinit the request chain */ + + for (cl = p->request->request_hunks; cl; cl = cl->next) { + cl->hunk->pos = cl->hunk->start; + } + } + + p->request_sent = 0; + p->timedout = 0; + + if (rc == NGX_OK) { + return ngx_http_proxy_send_request(p); + } + + /* rc == NGX_AGAIN */ + + ngx_add_timer(c->write, p->lcf->connect_timeout); + + return NGX_AGAIN; + } +} + +#endif + + static void ngx_http_proxy_send_request(ngx_http_proxy_ctx_t *p) { int rc; @@ -986,6 +1068,9 @@ static void ngx_http_proxy_send_response ep->single_buf = 1; } + /* TODO: ep->free_bufs = 0 if use ngx_create_chain_of_hunks() */ + ep->free_bufs = 1; + /* * event_pipe would do p->header_in->last += ep->preread_size * as though these bytes were read.