comparison src/http/modules/proxy/ngx_http_event_proxy_handler.c @ 81:b2ece31c976a

nginx-0.0.1-2003-04-24-18:46:08 import
author Igor Sysoev <igor@sysoev.ru>
date Thu, 24 Apr 2003 14:46:08 +0000
parents 939bc7cd9a90
children fccdb921e8b8
comparison
equal deleted inserted replaced
80:939bc7cd9a90 81:b2ece31c976a
16 #include <ngx_http_event_proxy_handler.h> 16 #include <ngx_http_event_proxy_handler.h>
17 17
18 18
19 /* STUB */ 19 /* STUB */
20 typedef struct { 20 typedef struct {
21 int dummy; 21 int type;
22 } ngx_cache_header_t; 22 } ngx_cache_header_t;
23
23 24
24 static int ngx_http_proxy_handler(ngx_http_request_t *r); 25 static int ngx_http_proxy_handler(ngx_http_request_t *r);
25 26
26 static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p); 27 static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p);
27 static int ngx_http_proxy_process_upstream(ngx_http_proxy_ctx_t *p, 28 static int ngx_http_proxy_process_upstream(ngx_http_proxy_ctx_t *p,
607 if (ngx_add_event(rev, NGX_READ_EVENT, event) != NGX_OK) { 608 if (ngx_add_event(rev, NGX_READ_EVENT, event) != NGX_OK) {
608 return NGX_HTTP_INTERNAL_SERVER_ERROR; 609 return NGX_HTTP_INTERNAL_SERVER_ERROR;
609 } 610 }
610 } 611 }
611 612
612 wev->event_handler = rev->event_handler = 613 rev->event_handler = ngx_http_proxy_process_upstream_event;
613 ngx_http_proxy_process_upstream_event; 614 p->request->connection->write->event_handler = NULL;
614 615
615 p->state_write_upstream_handler = ngx_http_proxy_send_request; 616 p->state_write_upstream_handler = ngx_http_proxy_send_request;
616 p->state_read_upstream_handler = ngx_http_proxy_init_upstream; 617 p->state_read_upstream_handler = ngx_http_proxy_init_upstream;
617 618
618 /* The connection has been established */ 619 /* The connection has been established */
1085 1086
1086 if (p->event_proxy->fatal_error) { 1087 if (p->event_proxy->fatal_error) {
1087 return NGX_HTTP_INTERNAL_SERVER_ERROR; 1088 return NGX_HTTP_INTERNAL_SERVER_ERROR;
1088 } 1089 }
1089 1090
1090 if (p->event_proxy->upstream_eof && p->event_proxy->upstream_error) { 1091 if (p->event_proxy->upstream_eof || p->event_proxy->upstream_error) {
1091 rc = ngx_event_close_connection(p->connection->read); 1092 rc = ngx_event_close_connection(p->connection->read);
1092 } 1093 }
1093 1094
1094 return rc; 1095 return rc;
1095 } 1096 }
1096 1097
1097 1098
1099 static int ngx_http_proxy_process_client_event(ngx_event_t *ev)
1100 {
1101 ngx_connection_t *c;
1102 ngx_http_request_t *r;
1103 ngx_http_proxy_ctx_t *p;
1104
1105 c = (ngx_connection_t *) ev->data;
1106 r = (ngx_http_request_t *) c->data;
1107 p = (ngx_http_proxy_ctx_t *)
1108 ngx_http_get_module_ctx(r, ngx_http_proxy_module_ctx);
1109
1110 return ngx_http_proxy_process_upstream(p, ev);
1111 }
1112
1113
1098 static int ngx_http_proxy_write_upstream_body(ngx_http_proxy_ctx_t *p) 1114 static int ngx_http_proxy_write_upstream_body(ngx_http_proxy_ctx_t *p)
1099 { 1115 {
1100 return ngx_event_proxy_write_to_downstream(p->event_proxy); 1116 return ngx_event_proxy_write_to_downstream(p->event_proxy);
1101 } 1117 }
1102 1118
1103 1119
1104 1120
1105 1121
1106 static int ngx_http_proxy_finalize_request(ngx_http_proxy_ctx_t *p, int error) 1122 static int ngx_http_proxy_finalize_request(ngx_http_proxy_ctx_t *p, int error)
1107 { 1123 {
1124 #if 0
1125
1126 if (p->event_proxy->upstream_eof) {
1127 rc = ngx_event_close_connection(p->connection->read);
1128 link cache;
1129 }
1130
1131 if (p->event_proxy->upstream_error) {
1132 rc = ngx_event_close_connection(p->connection->read);
1133 }
1134
1135 if (p->event_proxy->downstream_error) {
1136 rc = ngx_event_close_connection(p->request->connection->write);
1137 }
1138
1139 #endif
1140
1108 return ngx_http_finalize_request(p->request, error); 1141 return ngx_http_finalize_request(p->request, error);
1109 } 1142 }
1110 1143
1111 1144
1112 static int ngx_http_proxy_error(ngx_http_request_t *r, ngx_http_proxy_ctx_t *p, 1145 static int ngx_http_proxy_error(ngx_http_request_t *r, ngx_http_proxy_ctx_t *p,