Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/http
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2003-10-31 10:10:36 +0300
committerIgor Sysoev <igor@sysoev.ru>2003-10-31 10:10:36 +0300
commit219d44dd5d6a2726f39dbb1fdb9ca2a66fd2ee24 (patch)
tree84da926421cdaabbe60205b3bf24d53825922510 /src/http
parentb5910d497e51bac754b0a5bdbd58318b653e0859 (diff)
nginx-0.0.1-2003-10-31-10:10:36 import
Diffstat (limited to 'src/http')
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_handler.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c
index 053b7b598..52c0481dd 100644
--- 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_http_request_t *r)
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_handler(ngx_event_t *wev)
}
+#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(ngx_http_proxy_ctx_t *p)
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.