nginx-0.0.1-2003-10-06-07:56:42 import

This commit is contained in:
Igor Sysoev 2003-10-06 03:56:42 +00:00
parent e677922487
commit 1dd4ac8a8b
2 changed files with 30 additions and 9 deletions

View File

@ -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)
{

View File

@ -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_ */