diff options
author | Igor Sysoev <igor@sysoev.ru> | 2005-07-14 16:51:53 +0400 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2005-07-14 16:51:53 +0400 |
commit | 187b7d95589f674ce3262b05c311554bcd8f847c (patch) | |
tree | 0ac48dad3e3204d12837c2562d99020eafe29038 /src/http/ngx_http_upstream.c | |
parent | b3ad9f30d960bd1dcc3d8fd5c9963bf3e93bb7b3 (diff) |
nginx-0.1.39-RELEASE importrelease-0.1.39
*) The changes in the ngx_http_charset_module: the "default_charset"
directive was canceled; the "charset" directive sets the response
charset; the "source_charset" directive sets the source charset only.
*) Bugfix: the backend "WWW-Authenticate" header line did not
transferred while the 401 response code redirecting.
*) Bugfix: the ngx_http_proxy_module and ngx_http_fastcgi_module may
close a connection before anything was transferred to a client; the
bug had appeared in 0.1.38.
*) Workaround: the Linux glibc crypt_r() initialization bug.
*) Bugfix: the ngx_http_ssi_module did not support the relative URI in
the "include virtual" command.
*) Bugfix: if the backend response had the "Location" header line and
nginx should not rewrite this line, then the 500 code response body
was transferred; the bug had appeared in 0.1.29.
*) Bugfix: some directives of the ngx_http_proxy_module and
ngx_http_fastcgi_module were not inherited from the server to the
location level; the bug had appeared in 0.1.29.
*) Bugfix: the ngx_http_ssl_module did not support the certificate
chain.
*) Bugfix: the ngx_http_autoindex_module did not show correctly the
long file names; the bug had appeared in 0.1.38.
*) Bugfixes in IMAP/POP3 proxy in interaction with a backend at the
login state.
Diffstat (limited to 'src/http/ngx_http_upstream.c')
-rw-r--r-- | src/http/ngx_http_upstream.c | 54 |
1 files changed, 42 insertions, 12 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index 8571b869b..4b877a3fb 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -103,6 +103,11 @@ ngx_http_upstream_header_t ngx_http_upstream_headers_in[] = { ngx_http_upstream_conditional_copy_header_line, offsetof(ngx_http_upstream_conf_t, pass_server), 0 }, + { ngx_string("WWW-Authenticate"), + ngx_http_upstream_process_header_line, + offsetof(ngx_http_upstream_headers_in_t, www_authenticate), + ngx_http_upstream_copy_header_line, 0, 0 }, + { ngx_string("Location"), ngx_http_upstream_ignore_header_line, 0, ngx_http_upstream_rewrite_location, 0, 0 }, @@ -113,7 +118,7 @@ ngx_http_upstream_header_t ngx_http_upstream_headers_in[] = { { ngx_string("Set-Cookie"), ngx_http_upstream_ignore_header_line, 0, - ngx_http_upstream_copy_header_line, 0, 1 }, + ngx_http_upstream_copy_header_line, 0, 0 }, { ngx_string("Cache-Control"), ngx_http_upstream_process_multi_header_lines, @@ -386,9 +391,6 @@ ngx_http_upstream_check_broken_connection(ngx_http_request_t *r, return; } - ev->eof = 1; - c->closed = 1; - if (n == -1) { if (err == NGX_EAGAIN) { return; @@ -400,6 +402,9 @@ ngx_http_upstream_check_broken_connection(ngx_http_request_t *r, err = 0; } + ev->eof = 1; + c->closed = 1; + if (!u->cachable && u->peer.connection) { ngx_log_error(NGX_LOG_INFO, ev->log, err, "client closed prematurely connection, " @@ -851,7 +856,7 @@ ngx_http_upstream_process_header(ngx_event_t *rev) /* rc == NGX_OK */ - if (r->headers_out.status == NGX_HTTP_INTERNAL_SERVER_ERROR) { + if (u->headers_in.status_n == NGX_HTTP_INTERNAL_SERVER_ERROR) { if (u->peer.tries > 1 && (u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_HTTP_500)) @@ -867,14 +872,14 @@ ngx_http_upstream_process_header(ngx_event_t *rev) && (u->conf->use_stale & NGX_HTTP_UPSTREAM_FT_HTTP_500)) { ngx_http_upstream_finalize_request(r, u, - ngx_http_send_cached_response(r)); + ngx_http_send_cached_response(r)); return; } #endif } - if (r->headers_out.status == NGX_HTTP_NOT_FOUND + if (u->headers_in.status_n == NGX_HTTP_NOT_FOUND && u->peer.tries > 1 && u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_HTTP_404) { @@ -883,7 +888,7 @@ ngx_http_upstream_process_header(ngx_event_t *rev) } - if (r->headers_out.status >= NGX_HTTP_BAD_REQUEST + if (u->headers_in.status_n >= NGX_HTTP_BAD_REQUEST && u->conf->redirect_errors && r->err_ctx == NULL) { @@ -893,9 +898,25 @@ ngx_http_upstream_process_header(ngx_event_t *rev) err_page = clcf->error_pages->elts; for (i = 0; i < clcf->error_pages->nelts; i++) { - if (err_page[i].status == (ngx_int_t) r->headers_out.status) { + if (err_page[i].status == (ngx_int_t) u->headers_in.status_n) { + + if (u->headers_in.status_n == NGX_HTTP_UNAUTHORIZED) { + + r->headers_out.www_authenticate = + ngx_list_push(&r->headers_out.headers); + + if (r->headers_out.www_authenticate == NULL) { + ngx_http_upstream_finalize_request(r, u, + NGX_HTTP_INTERNAL_SERVER_ERROR); + return; + } + + *r->headers_out.www_authenticate = + *u->headers_in.www_authenticate; + } + ngx_http_upstream_finalize_request(r, u, - r->headers_out.status); + u->headers_in.status_n); return; } } @@ -938,8 +959,6 @@ ngx_http_upstream_process_header(ngx_event_t *rev) } } - r->headers_out.status_line.len = 0; - ngx_http_internal_redirect(r, &r->upstream->headers_in.x_accel_redirect->value, NULL); @@ -1001,6 +1020,9 @@ ngx_http_upstream_send_response(ngx_http_request_t *r, ngx_http_upstream_t *u) } } + r->headers_out.status = u->headers_in.status_n; + r->headers_out.status_line = u->headers_in.status_line; + rc = ngx_http_send_header(r); if (rc == NGX_ERROR || rc > NGX_OK) { @@ -1622,6 +1644,10 @@ ngx_http_upstream_rewrite_location(ngx_http_request_t *r, ngx_table_elt_t *h, if (r->upstream->rewrite_redirect) { rc = r->upstream->rewrite_redirect(r, ho, 0); + if (rc == NGX_DECLINED) { + return NGX_OK; + } + if (rc == NGX_OK) { r->headers_out.location = ho; @@ -1667,6 +1693,10 @@ ngx_http_upstream_rewrite_refresh(ngx_http_request_t *r, ngx_table_elt_t *h, return NGX_OK; } + if (rc == NGX_DECLINED) { + return NGX_OK; + } + #if (NGX_DEBUG) if (rc == NGX_OK) { ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |