Welcome! Log In Create A New Profile

Advanced

Re: [PATCH] Upstream: support named location for X-Accel-Redirect

Maxim Dounin
November 11, 2014 09:04AM
Hello!

On Tue, Nov 11, 2014 at 09:33:00AM +0900, Toshikuni Fukaya wrote:

> Hi,
>
> (2014/11/11 3:02), Maxim Dounin wrote:
> >Hello!
> >
> >On Tue, Nov 04, 2014 at 08:18:44PM +0900, Toshikuni Fukaya wrote:
> >
> >># HG changeset patch
> >># User Toshikuni Fukaya <toshikuni-fukaya@cybozu.co.jp>
> >># Date 1415098583 -32400
> >># Node ID 6f4517db02a8cd4068b9378bd93fe6290f54720d
> >># Parent dff86e2246a53b0f4a61935cd5c8c0a0f66d0ca2
> >>Upstream: support named location for X-Accel-Redirect.
> >>
> >>diff -r dff86e2246a5 -r 6f4517db02a8 src/http/ngx_http_upstream.c
> >>--- a/src/http/ngx_http_upstream.c Mon Aug 25 13:41:31 2014 +0400
> >>+++ b/src/http/ngx_http_upstream.c Tue Nov 04 19:56:23 2014 +0900
> >>@@ -2218,19 +2218,25 @@
> >> }
> >>
> >> uri = u->headers_in.x_accel_redirect->value;
> >>- ngx_str_null(&args);
> >>- flags = NGX_HTTP_LOG_UNSAFE;
> >>-
> >>- if (ngx_http_parse_unsafe_uri(r, &uri, &args, &flags) != NGX_OK) {
> >>- ngx_http_finalize_request(r, NGX_HTTP_NOT_FOUND);
> >>- return NGX_DONE;
> >>- }
> >>-
> >>- if (r->method != NGX_HTTP_HEAD) {
> >>- r->method = NGX_HTTP_GET;
> >>- }
> >>-
> >>- ngx_http_internal_redirect(r, &uri, &args);
> >>+
> >>+ if (uri.len > 0 && uri.data[0] == '@') {
> >>+ ngx_http_named_location(r, &uri);
> >>+ } else {
> >>+ ngx_str_null(&args);
> >>+ flags = NGX_HTTP_LOG_UNSAFE;
> >
> >
> >The uri here is required to be null-terminated, so the uri.len
> >check can be safely dropped. With this and an extra line added as
> >per style:
> >
> >diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
> >--- a/src/http/ngx_http_upstream.c
> >+++ b/src/http/ngx_http_upstream.c
> >@@ -2219,8 +2219,9 @@ ngx_http_upstream_process_headers(ngx_ht
> >
> > uri = u->headers_in.x_accel_redirect->value;
> >
> >- if (uri.len > 0 && uri.data[0] == '@') {
> >+ if (uri.data[0] == '@') {
> > ngx_http_named_location(r, &uri);
> >+
> > } else {
> > ngx_str_null(&args);
> > flags = NGX_HTTP_LOG_UNSAFE;
> >
> >
> >Please let me know if looks good for you.
> >
>
> It's good. Thanks a lot for explanation of nginx internals.

Thanks, committed.

--
Maxim Dounin
http://nginx.org/

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Upstream: support named location for X-Accel-Redirect

Toshikuni Fukaya 647 November 04, 2014 06:20AM

Re: [PATCH] Upstream: support named location for X-Accel-Redirect

Igor Sysoev 641 November 07, 2014 11:02AM

Re: [PATCH] Upstream: support named location for X-Accel-Redirect

Toshikuni Fukaya 321 November 09, 2014 07:56PM

Re: [PATCH] Upstream: support named location for X-Accel-Redirect

Valentin V. Bartenev 391 November 10, 2014 03:44AM

Re: [PATCH] Upstream: support named location for X-Accel-Redirect

Igor Sysoev 827 November 10, 2014 04:10AM

Re: [PATCH] Upstream: support named location for X-Accel-Redirect

Maxim Dounin 347 November 10, 2014 01:04PM

Re: [PATCH] Upstream: support named location for X-Accel-Redirect

Toshikuni Fukaya 343 November 10, 2014 07:34PM

Re: [PATCH] Upstream: support named location for X-Accel-Redirect

Maxim Dounin 393 November 11, 2014 09:04AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 160
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready