Mercurial > hg > nginx
comparison src/http/modules/ngx_http_event_proxy_handler.c @ 41:59e7c7f30d49
nginx-0.0.1-2002-12-26-19:26:23 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 26 Dec 2002 16:26:23 +0000 |
parents | 53cb81681040 |
children | 0e81ac0bb3e2 |
comparison
equal
deleted
inserted
replaced
40:d5d4f3bba6f0 | 41:59e7c7f30d49 |
---|---|
6 #include <ngx_hunk.h> | 6 #include <ngx_hunk.h> |
7 #include <ngx_event_write.h> | 7 #include <ngx_event_write.h> |
8 #include <ngx_http.h> | 8 #include <ngx_http.h> |
9 #include <ngx_http_event_proxy_handler.h> | 9 #include <ngx_http_event_proxy_handler.h> |
10 | 10 |
11 ngx_http_module_t ngx_http_proxy_module; | 11 ngx_http_module_t ngx_http_proxy_module_ctx; |
12 | 12 |
13 | 13 |
14 static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_request_t *r); | 14 static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_request_t *r); |
15 static int ngx_http_proxy_connect(ngx_http_request_t *r, | 15 static int ngx_http_proxy_connect(ngx_http_request_t *r, |
16 struct sockaddr_in *addr, | 16 struct sockaddr_in *addr, |
34 { | 34 { |
35 struct sockaddr_in addr; | 35 struct sockaddr_in addr; |
36 ngx_chain_t *chain; | 36 ngx_chain_t *chain; |
37 ngx_http_proxy_ctx_t *p; | 37 ngx_http_proxy_ctx_t *p; |
38 | 38 |
39 p = (ngx_http_proxy_ctx_t *) ngx_get_module_ctx(r, ngx_http_proxy_module); | 39 p = (ngx_http_proxy_ctx_t *) |
40 ngx_http_get_module_ctx(r, ngx_http_proxy_module_ctx); | |
40 | 41 |
41 if (p == NULL) | 42 if (p == NULL) |
42 ngx_http_create_ctx(r, p, ngx_http_proxy_module, | 43 ngx_http_create_ctx(r, p, ngx_http_proxy_module_ctx, |
43 sizeof(ngx_http_proxy_ctx_t)); | 44 sizeof(ngx_http_proxy_ctx_t)); |
44 | 45 |
45 chain = ngx_http_proxy_create_request(r); | 46 chain = ngx_http_proxy_create_request(r); |
46 if (chain == NULL) | 47 if (chain == NULL) |
47 return NGX_ERROR; | 48 return NGX_ERROR; |
242 ngx_http_request_t *r; | 243 ngx_http_request_t *r; |
243 ngx_http_proxy_ctx_t *p; | 244 ngx_http_proxy_ctx_t *p; |
244 | 245 |
245 c = (ngx_connection_t *) ev->data; | 246 c = (ngx_connection_t *) ev->data; |
246 r = (ngx_http_request_t *) c->data; | 247 r = (ngx_http_request_t *) c->data; |
247 p = (ngx_http_proxy_ctx_t *) ngx_get_module_ctx(r, ngx_http_proxy_module); | 248 p = (ngx_http_proxy_ctx_t *) |
249 ngx_http_get_module_ctx(r, ngx_http_proxy_module_ctx); | |
248 | 250 |
249 chain = ngx_event_write(c, p->out, 0); | 251 chain = ngx_event_write(c, p->out, 0); |
250 if (chain == (ngx_chain_t *) -1) | 252 if (chain == (ngx_chain_t *) -1) |
251 return NGX_ERROR; | 253 return NGX_ERROR; |
252 | 254 |
267 if (ev->timedout) | 269 if (ev->timedout) |
268 return NGX_ERROR; | 270 return NGX_ERROR; |
269 | 271 |
270 c = (ngx_connection_t *) ev->data; | 272 c = (ngx_connection_t *) ev->data; |
271 r = (ngx_http_request_t *) c->data; | 273 r = (ngx_http_request_t *) c->data; |
272 p = (ngx_http_proxy_ctx_t *) ngx_get_module_ctx(r, ngx_http_proxy_module); | 274 p = (ngx_http_proxy_ctx_t *) |
275 ngx_http_get_module_ctx(r, ngx_http_proxy_module_ctx); | |
273 | 276 |
274 if (p->header_in == NULL) { | 277 if (p->header_in == NULL) { |
275 ngx_test_null(p->header_in, | 278 ngx_test_null(p->header_in, |
276 ngx_create_temp_hunk(r->pool, | 279 ngx_create_temp_hunk(r->pool, |
277 /* STUB */ 1024 /**/, 0, 0), | 280 /* STUB */ 1024 /**/, 0, 0), |
387 if (ev->timedout) | 390 if (ev->timedout) |
388 return NGX_ERROR; | 391 return NGX_ERROR; |
389 | 392 |
390 c = (ngx_connection_t *) ev->data; | 393 c = (ngx_connection_t *) ev->data; |
391 r = (ngx_http_request_t *) c->data; | 394 r = (ngx_http_request_t *) c->data; |
392 p = (ngx_http_proxy_ctx_t *) ngx_get_module_ctx(r, ngx_http_proxy_module); | 395 p = (ngx_http_proxy_ctx_t *) |
396 ngx_http_get_module_ctx(r, ngx_http_proxy_module_ctx); | |
393 | 397 |
394 left = 0; | 398 left = 0; |
395 | 399 |
396 if (p->hunks->nelts > 0) { | 400 if (p->hunks->nelts > 0) { |
397 h = ((ngx_hunk_t **) p->hunks->elts)[p->hunks->nelts - 1]; | 401 h = ((ngx_hunk_t **) p->hunks->elts)[p->hunks->nelts - 1]; |
462 ngx_http_request_t *r; | 466 ngx_http_request_t *r; |
463 ngx_http_proxy_ctx_t *p; | 467 ngx_http_proxy_ctx_t *p; |
464 | 468 |
465 c = (ngx_connection_t *) ev->data; | 469 c = (ngx_connection_t *) ev->data; |
466 r = (ngx_http_request_t *) c->data; | 470 r = (ngx_http_request_t *) c->data; |
467 p = (ngx_http_proxy_ctx_t *) ngx_get_module_ctx(r, ngx_http_proxy_module); | 471 p = (ngx_http_proxy_ctx_t *) |
472 ngx_http_get_module_ctx(r, ngx_http_proxy_module_ctx); | |
468 | 473 |
469 do { | 474 do { |
470 h = ((ngx_hunk_t **) p->hunks->elts)[p->hunk_n]; | 475 h = ((ngx_hunk_t **) p->hunks->elts)[p->hunk_n]; |
471 | 476 |
472 rc = ngx_http_output_filter(r, h); | 477 rc = ngx_http_output_filter(r, h); |