Mercurial > hg > nginx
changeset 138:3b168e12bd2d
nginx-0.0.1-2003-10-06-07:56:42 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 06 Oct 2003 03:56:42 +0000 |
parents | 2a615b036870 |
children | 54307053f185 |
files | src/http/modules/proxy/ngx_http_proxy_handler.c src/http/modules/proxy/ngx_http_proxy_handler.h |
diffstat | 2 files changed, 30 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c +++ b/src/http/modules/proxy/ngx_http_proxy_handler.c @@ -16,6 +16,7 @@ static void ngx_http_proxy_process_upstr static void ngx_http_proxy_process_upstream_headers(ngx_event_t *rev); static ssize_t ngx_http_proxy_read_upstream_header(ngx_http_proxy_ctx_t *); static int ngx_http_proxy_parse_status_line(ngx_http_proxy_ctx_t *p); +static void ngx_http_proxy_next_upstream(ngx_http_proxy_ctx_t *p); static void ngx_http_proxy_close_connection(ngx_connection_t *c); static int ngx_http_proxy_init(ngx_cycle_t *cycle); @@ -386,8 +387,7 @@ static void ngx_http_proxy_process_upstr ngx_log_debug(rev->log, "http proxy process status line"); if (rev->timedout) { - ngx_http_proxy_close_connection(c); - ngx_http_finalize_request(p->request, NGX_HTTP_GATEWAY_TIME_OUT); + ngx_http_proxy_next_upstream(p); return; } @@ -405,7 +405,12 @@ static void ngx_http_proxy_process_upstr n = ngx_http_proxy_read_upstream_header(p); - if (n == NGX_AGAIN || n == NGX_ERROR) { + if (n == NGX_ERROR) { + ngx_http_proxy_next_upstream(p); + return; + } + + if (n == NGX_AGAIN) { return; } @@ -473,8 +478,7 @@ static void ngx_http_proxy_process_upstr ngx_log_debug(rev->log, "http proxy process header line"); if (rev->timedout) { - ngx_http_proxy_close_connection(c); - ngx_http_finalize_request(p->request, NGX_HTTP_GATEWAY_TIME_OUT); + ngx_http_proxy_next_upstream(p); return; } @@ -484,7 +488,12 @@ static void ngx_http_proxy_process_upstr if (rc == NGX_AGAIN) { n = ngx_http_proxy_read_upstream_header(p); - if (n == NGX_AGAIN || n == NGX_ERROR) { + if (n == NGX_ERROR) { + ngx_http_proxy_next_upstream(p); + return; + } + + if (n == NGX_AGAIN) { return; } } @@ -549,6 +558,7 @@ static void ngx_http_proxy_process_upstr #if 0 ngx_http_header_parse_error(r, rc); + ngx_http_proxy_next_upstream(p); #endif ngx_http_proxy_close_connection(c); ngx_http_finalize_request(p->request, NGX_HTTP_BAD_GATEWAY); @@ -622,8 +632,6 @@ static ssize_t ngx_http_proxy_read_upstr } if (n == 0 || n == NGX_ERROR) { - ngx_http_proxy_close_connection(p->upstream.connection); - ngx_http_finalize_request(p->request, NGX_HTTP_BAD_GATEWAY); return NGX_ERROR; } @@ -831,6 +839,18 @@ static int ngx_http_proxy_parse_status_l return NGX_AGAIN; } +static void ngx_http_proxy_next_upstream(ngx_http_proxy_ctx_t *p) +{ + if (p->upstream.connection) { + ngx_http_proxy_close_connection(p->upstream.connection); + p->upstream.connection = NULL; + + ngx_http_proxy_send_request(p); + } + + return; +} + static void ngx_http_proxy_close_connection(ngx_connection_t *c) {
--- a/src/http/modules/proxy/ngx_http_proxy_handler.h +++ b/src/http/modules/proxy/ngx_http_proxy_handler.h @@ -52,6 +52,7 @@ struct ngx_http_proxy_ctx_s { int location_len; ngx_str_t host_header; + /* used to parse an upstream HTTP header */ char *status_start; char *status_end; int status_count; @@ -61,7 +62,7 @@ struct ngx_http_proxy_ctx_s { }; -#define NGX_HTTP_PROXY_PARSE_NO_HEADER 10 +#define NGX_HTTP_PROXY_PARSE_NO_HEADER 20 #endif /* _NGX_HTTP_PROXY_HANDLER_H_INCLUDED_ */