Mercurial > hg > nginx
comparison src/http/modules/proxy/ngx_http_proxy_upstream.c @ 298:4a3f18406832
nginx-0.0.3-2004-03-30-10:27:36 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 30 Mar 2004 06:27:36 +0000 |
parents | ee394e997c77 |
children | 00c5660d2707 |
comparison
equal
deleted
inserted
replaced
297:ee394e997c77 | 298:4a3f18406832 |
---|---|
68 if (!(rb = ngx_pcalloc(r->pool, sizeof(ngx_http_request_body_t)))) { | 68 if (!(rb = ngx_pcalloc(r->pool, sizeof(ngx_http_request_body_t)))) { |
69 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 69 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
70 } | 70 } |
71 r->request_body = rb; | 71 r->request_body = rb; |
72 | 72 |
73 if (r->headers_in.content_length_n > 0) { | 73 if (r->headers_in.content_length_n <= 0) { |
74 | 74 ngx_http_proxy_init_upstream(p); |
75 if (!(tf = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t)))) { | 75 return NGX_DONE; |
76 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 76 } |
77 } | 77 |
78 | 78 if (!(tf = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t)))) { |
79 tf->file.fd = NGX_INVALID_FILE; | 79 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
80 tf->file.log = r->connection->log; | 80 } |
81 tf->path = p->lcf->temp_path; | 81 |
82 tf->pool = r->pool; | 82 tf->file.fd = NGX_INVALID_FILE; |
83 tf->warn = "a client request body is buffered to a temporary file"; | 83 tf->file.log = r->connection->log; |
84 /* tf->persistent = 0; */ | 84 tf->path = p->lcf->temp_path; |
85 | 85 tf->pool = r->pool; |
86 rb->buf_size = p->lcf->request_buffer_size; | 86 tf->warn = "a client request body is buffered to a temporary file"; |
87 rb->handler = ngx_http_proxy_init_upstream; | 87 /* tf->persistent = 0; */ |
88 rb->data = p; | 88 |
89 /* rb->bufs = NULL; */ | 89 rb->buf_size = p->lcf->request_buffer_size; |
90 /* rb->buf = NULL; */ | 90 rb->handler = ngx_http_proxy_init_upstream; |
91 /* rb->rest = 0; */ | 91 rb->data = p; |
92 | 92 /* rb->bufs = NULL; */ |
93 rb->temp_file = tf; | 93 /* rb->buf = NULL; */ |
94 | 94 /* rb->rest = 0; */ |
95 rc = ngx_http_read_client_request_body(r); | 95 |
96 | 96 rb->temp_file = tf; |
97 if (rc == NGX_AGAIN) { | 97 |
98 return NGX_DONE; | 98 rc = ngx_http_read_client_request_body(r); |
99 } | 99 |
100 | 100 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { |
101 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { | 101 return rc; |
102 return rc; | 102 } |
103 } | |
104 } | |
105 | |
106 ngx_http_proxy_init_upstream(p); | |
107 | 103 |
108 return NGX_DONE; | 104 return NGX_DONE; |
109 } | 105 } |
110 | 106 |
111 | 107 |
321 ngx_http_proxy_log_ctx_t *ctx; | 317 ngx_http_proxy_log_ctx_t *ctx; |
322 | 318 |
323 r = p->request; | 319 r = p->request; |
324 | 320 |
325 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 321 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
326 "http proxy set timer: %d", | 322 "http proxy init upstream, client timer: %d", |
327 r->connection->read->timer_set); | 323 r->connection->read->timer_set); |
328 | 324 |
329 if (r->connection->read->timer_set) { | 325 if (r->connection->read->timer_set) { |
330 ngx_del_timer(r->connection->read); | 326 ngx_del_timer(r->connection->read); |
331 } | 327 } |
328 | |
329 r->connection->read->event_handler = ngx_http_proxy_check_broken_connection; | |
332 | 330 |
333 if ((ngx_event_flags & (NGX_USE_CLEAR_EVENT|NGX_HAVE_KQUEUE_EVENT)) | 331 if ((ngx_event_flags & (NGX_USE_CLEAR_EVENT|NGX_HAVE_KQUEUE_EVENT)) |
334 && !r->connection->write->active) | 332 && !r->connection->write->active) |
335 { | 333 { |
336 /* kqueue allows to detect when client closes prematurely connection */ | 334 /* kqueue allows to detect when client closes prematurely connection */ |