Welcome! Log In Create A New Profile

Advanced

Re: Does the nginx support "Header append ..."?

agentzh
March 01, 2011 04:02AM
On Mon, Feb 28, 2011 at 5:36 PM, sunjipeng_neu <nginx-forum@nginx.us> wrote:
> But for Nginx, neither "add_header" nor "more_set_headers" directive can
> "append" a value to an exsisting headers.
>

Yes, ngx_headers_more does not support header appending yet. But it is
a TODO and patches are also welcomed.

> Especially, the "more_set_headers" will create a duplicate headers of
> the same name. i.e.
>
> Vary: Host
> Vary: User-Agent
>

I cannot reproduce this with nginx 0.8.54 + ngx_headers_more v0.14.
I'm using the following test case:

location /foo {
more_set_headers 'Vary: gbk';
echo hello;
}

location /len {
default_type 'text/plain';
more_set_headers 'Vary: hello';
proxy_pass http://127.0.0.1:$server_port/foo;
}

Then we get

$ curl localhost:1984/len
HTTP/1.1 200 OK
Server: nginx/0.8.54 (without pool)
Date: Tue, 01 Mar 2011 08:52:13 GMT
Content-Type: text/plain
Connection: keep-alive
Content-Length: 6
Vary: hello

hello

$ curl localhost:1984/foo
HTTP/1.1 200 OK
Server: nginx/0.8.54 (without pool)
Date: Tue, 01 Mar 2011 08:51:31 GMT
Content-Type: text/plain
Transfer-Encoding: chunked
Connection: keep-alive
Vary: gbk

hello

Note that accessing /len does not yield duplicate Vary headers. Using
telnet gives exactly the same results.

Could you please provide a minimal sample config that could reproduce
this problem? It's preferable to create a ticket at the GitHub issues
panel though:

https://github.com/agentzh/headers-more-nginx-module/issues

> So, What's the reason for it? How should I do for the "append"?
>

ngx_lua does allow header append, but may not be meaningful in your
context. Here's a small Lua example though:

ngx.header["Vary"] = ngx.header["Vary"] .. ", UserAgent"

It seems like a good chance to implement the
"output_header_filter_by_lua" directive ;)

Cheers,
-agentzh

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

Does the nginx support "Header append ..."?

sunjipeng_neu February 28, 2011 04:36AM

Re: Does the nginx support "Header append ..."?

agentzh March 01, 2011 04:02AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 310
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