comparison src/http/ngx_http_upstream.c @ 4719:1eab1a2c661e stable-1.2

Merge of r4651: proxy_cookie_* fix. 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
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 02 Jul 2012 15:43:50 +0000
parents 67653855682e
children c48902a053d6 6fc86fe0b586
comparison
equal deleted inserted replaced
4718:a05e7b09af5a 4719:1eab1a2c661e
3675 3675
3676 static ngx_int_t 3676 static ngx_int_t
3677 ngx_http_upstream_rewrite_set_cookie(ngx_http_request_t *r, ngx_table_elt_t *h, 3677 ngx_http_upstream_rewrite_set_cookie(ngx_http_request_t *r, ngx_table_elt_t *h,
3678 ngx_uint_t offset) 3678 ngx_uint_t offset)
3679 { 3679 {
3680 ngx_int_t rc;
3680 ngx_table_elt_t *ho; 3681 ngx_table_elt_t *ho;
3681 3682
3682 ho = ngx_list_push(&r->headers_out.headers); 3683 ho = ngx_list_push(&r->headers_out.headers);
3683 if (ho == NULL) { 3684 if (ho == NULL) {
3684 return NGX_ERROR; 3685 return NGX_ERROR;
3685 } 3686 }
3686 3687
3687 *ho = *h; 3688 *ho = *h;
3688 3689
3689 if (r->upstream->rewrite_cookie) { 3690 if (r->upstream->rewrite_cookie) {
3690 return r->upstream->rewrite_cookie(r, ho); 3691 rc = r->upstream->rewrite_cookie(r, ho);
3692
3693 if (rc == NGX_DECLINED) {
3694 return NGX_OK;
3695 }
3696
3697 #if (NGX_DEBUG)
3698 if (rc == NGX_OK) {
3699 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
3700 "rewritten cookie: \"%V\"", &ho->value);
3701 }
3702 #endif
3703
3704 return rc;
3691 } 3705 }
3692 3706
3693 return NGX_OK; 3707 return NGX_OK;
3694 } 3708 }
3695 3709