diff options
author | Igor Sysoev <igor@sysoev.ru> | 2003-10-06 03:56:42 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2003-10-06 03:56:42 +0000 |
commit | 1dd4ac8a8bac777d433249eac4a6b9239e4efbcc (patch) | |
tree | d536ac83d11c59ce7f2e5b267c7b9b6fb3132384 | |
parent | e677922487a45b840663cf97ef28b37d8cf1ac8c (diff) | |
download | nginx-1dd4ac8a8bac777d433249eac4a6b9239e4efbcc.tar.gz nginx-1dd4ac8a8bac777d433249eac4a6b9239e4efbcc.zip |
nginx-0.0.1-2003-10-06-07:56:42 import
-rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.c | 36 | ||||
-rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.h | 3 |
2 files changed, 30 insertions, 9 deletions
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c index e6c448563..735db356d 100644 --- 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_upstream_status_line(ngx_event_t *rev); 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_upstream_status_line(ngx_event_t *rev) 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_upstream_status_line(ngx_event_t *rev) 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_upstream_headers(ngx_event_t *rev) 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_upstream_headers(ngx_event_t *rev) 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_upstream_headers(ngx_event_t *rev) #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_upstream_header(ngx_http_proxy_ctx_t *p) } 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_line(ngx_http_proxy_ctx_t *p) 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) { diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.h b/src/http/modules/proxy/ngx_http_proxy_handler.h index 1d51360f0..9aeb965a0 100644 --- 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_ */ |