diff options
| author | Valentin Bartenev <vbart@nginx.com> | 2012-05-30 12:30:03 +0000 |
|---|---|---|
| committer | Valentin Bartenev <vbart@nginx.com> | 2012-05-30 12:30:03 +0000 |
| commit | d8ec4910ce8b69c5dac3739b5a09503d49521340 (patch) | |
| tree | f304884bd05e2a17e44da8d0f56536df74af353e /src | |
| parent | 94d8df609872916b4899f12269633447dd06e182 (diff) | |
| download | nginx-d8ec4910ce8b69c5dac3739b5a09503d49521340.tar.gz nginx-d8ec4910ce8b69c5dac3739b5a09503d49521340.tar.bz2 | |
Fixed returned value handling from the cookie rewrite handler.
If the "proxy_cookie_domain" or "proxy_cookie_path" directive is used and there
are no matches in Set-Cookie header then ngx_http_proxy_rewrite_cookie() returns
NGX_DECLINED to indicate that the header was not rewritten. Returning this value
further from the upstream headers copy handler resulted in 500 error response.
See here for report:
http://mailman.nginx.org/pipermail/nginx/2012-May/033858.html
Diffstat (limited to 'src')
| -rw-r--r-- | src/http/ngx_http_upstream.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index 70a4e1668..3730a2026 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -3677,6 +3677,7 @@ static ngx_int_t ngx_http_upstream_rewrite_set_cookie(ngx_http_request_t *r, ngx_table_elt_t *h, ngx_uint_t offset) { + ngx_int_t rc; ngx_table_elt_t *ho; ho = ngx_list_push(&r->headers_out.headers); @@ -3687,7 +3688,20 @@ ngx_http_upstream_rewrite_set_cookie(ngx_http_request_t *r, ngx_table_elt_t *h, *ho = *h; if (r->upstream->rewrite_cookie) { - return r->upstream->rewrite_cookie(r, ho); + rc = r->upstream->rewrite_cookie(r, ho); + + 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, + "rewritten cookie: \"%V\"", &ho->value); + } +#endif + + return rc; } return NGX_OK; |
