Mercurial > hg > nginx
comparison 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 |
comparison
equal
deleted
inserted
replaced
167:8aef3c72e5da | 168:ba5dbb949603 |
---|---|
227 /* STUB */ r->temp_file->persistent = 1; | 227 /* STUB */ r->temp_file->persistent = 1; |
228 | 228 |
229 r->request_body_handler = ngx_http_proxy_init_request; | 229 r->request_body_handler = ngx_http_proxy_init_request; |
230 r->data = p; | 230 r->data = p; |
231 | 231 |
232 /* TODO: we ignore return value of ngx_http_read_client_request_body */ | |
232 ngx_http_read_client_request_body(r, p->lcf->request_buffer_size); | 233 ngx_http_read_client_request_body(r, p->lcf->request_buffer_size); |
233 | 234 |
234 return NGX_DONE; | 235 return NGX_DONE; |
235 } | 236 } |
236 | 237 |
445 | 446 |
446 ngx_http_proxy_send_request(p); | 447 ngx_http_proxy_send_request(p); |
447 | 448 |
448 return; | 449 return; |
449 } | 450 } |
451 | |
452 | |
453 #if 0 | |
454 | |
455 static int ngx_http_proxy_connect(ngx_http_proxy_ctx_t *p) | |
456 { | |
457 int rc; | |
458 ngx_chain_t *cl; | |
459 ngx_connection_t *c; | |
460 | |
461 for ( ;; ) { | |
462 p->action = "connecting to upstream"; | |
463 | |
464 rc = ngx_event_connect_peer(&p->upstream); | |
465 | |
466 if (rc == NGX_ERROR) { | |
467 ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR); | |
468 return NGX_DONE; | |
469 } | |
470 | |
471 if (rc == NGX_CONNECT_ERROR) { | |
472 ngx_event_connect_peer_failed(&p->upstream); | |
473 | |
474 #if 0 | |
475 /* TODO: make separate func and call it from next_upstream */ | |
476 | |
477 if (!(state = ngx_push_array(p->states))) { | |
478 ngx_http_proxy_finalize_request(p, | |
479 NGX_HTTP_INTERNAL_SERVER_ERROR); | |
480 return NGX_DONE; | |
481 } | |
482 | |
483 state->status = NGX_HTTP_BAD_GATEWAY; | |
484 state->peer = | |
485 p->upstream.peers->peers[p->upstream.cur_peer].addr_port_text; | |
486 | |
487 #endif | |
488 | |
489 if (p->upstream.tries == 0) { | |
490 ngx_http_proxy_finalize_request(p, NGX_HTTP_BAD_GATEWAY); | |
491 return NGX_DONE; | |
492 } | |
493 | |
494 continue; | |
495 } | |
496 | |
497 p->upstream.connection->data = p; | |
498 p->upstream.connection->write->event_handler = | |
499 ngx_http_proxy_send_request_handler; | |
500 p->upstream.connection->read->event_handler = | |
501 ngx_http_proxy_process_upstream_status_line; | |
502 | |
503 c = p->upstream.connection; | |
504 c->pool = p->request->pool; | |
505 c->read->log = c->write->log = c->log = p->request->connection->log; | |
506 | |
507 if (p->upstream.tries > 1 && p->request_sent) { | |
508 | |
509 /* reinit the request chain */ | |
510 | |
511 for (cl = p->request->request_hunks; cl; cl = cl->next) { | |
512 cl->hunk->pos = cl->hunk->start; | |
513 } | |
514 } | |
515 | |
516 p->request_sent = 0; | |
517 p->timedout = 0; | |
518 | |
519 if (rc == NGX_OK) { | |
520 return ngx_http_proxy_send_request(p); | |
521 } | |
522 | |
523 /* rc == NGX_AGAIN */ | |
524 | |
525 ngx_add_timer(c->write, p->lcf->connect_timeout); | |
526 | |
527 return NGX_AGAIN; | |
528 } | |
529 } | |
530 | |
531 #endif | |
450 | 532 |
451 | 533 |
452 static void ngx_http_proxy_send_request(ngx_http_proxy_ctx_t *p) | 534 static void ngx_http_proxy_send_request(ngx_http_proxy_ctx_t *p) |
453 { | 535 { |
454 int rc; | 536 int rc; |
983 if (ngx_event_flags & NGX_USE_AIO_EVENT) { | 1065 if (ngx_event_flags & NGX_USE_AIO_EVENT) { |
984 | 1066 |
985 /* the posted aio operation can currupt shadow buf */ | 1067 /* the posted aio operation can currupt shadow buf */ |
986 ep->single_buf = 1; | 1068 ep->single_buf = 1; |
987 } | 1069 } |
1070 | |
1071 /* TODO: ep->free_bufs = 0 if use ngx_create_chain_of_hunks() */ | |
1072 ep->free_bufs = 1; | |
988 | 1073 |
989 /* | 1074 /* |
990 * event_pipe would do p->header_in->last += ep->preread_size | 1075 * event_pipe would do p->header_in->last += ep->preread_size |
991 * as though these bytes were read. | 1076 * as though these bytes were read. |
992 */ | 1077 */ |