now we allow overriding multi-value headers.

This commit is contained in:
agentzh (章亦春) 2010-11-05 14:58:42 +08:00
Родитель 10deafbf7d
Коммит f33ac9d2e3
3 изменённых файлов: 74 добавлений и 4 удалений

Просмотреть файл

@ -289,12 +289,27 @@ Will yield
in the response headers. Only array-like tables are accepted.
Note that, for those standard headers that only accepts a single value, like Content-Type, only the last element
in the (array) table will take effect. So
ngx.header.content_type = {'a', 'b'}
is equivalent to
ngx.header.content_type = 'b'
Setting a slot to nil effectively removes it from the response headers:
ngx.header["X-My-Header"] = nil;
same does assigning an empty table:
ngx.header["X-My-Header"] = {};
Reading values from ngx.header.HEADER is not implemented yet.
ngx.exec(uri, args)
----------
-------------------
Does an internal redirect to uri with args.

Просмотреть файл

@ -153,7 +153,8 @@ ngx_http_set_header_helper(ngx_http_request_t *r, ngx_http_lua_header_val_t *hv,
*output_header = &h[i];
}
return NGX_OK;
/* return NGX_OK; */
matched = 1;
}
}

Просмотреть файл

@ -105,7 +105,7 @@ Hello
=== TEST 6: set response content-type header
=== TEST 6: set multi response content-type header
--- config
location /read {
content_by_lua '
@ -122,7 +122,7 @@ Hello
=== TEST 6: set response content-type header
=== TEST 7: set response content-type header
--- config
location /read {
content_by_lua '
@ -137,3 +137,57 @@ Content-Type: bc
--- response_body
Hello
=== TEST 8: set multi response content-type header and clears it
--- config
location /read {
content_by_lua '
ngx.header["X-Foo"] = {"a", "bc"}
ngx.header["X-Foo"] = {}
ngx.say("Hello")
';
}
--- request
GET /read
--- response_headers
!X-Foo
--- response_body
Hello
=== TEST 9: set multi response content-type header and clears it
--- config
location /read {
content_by_lua '
ngx.header["X-Foo"] = {"a", "bc"}
ngx.header["X-Foo"] = nil
ngx.say("Hello")
';
}
--- request
GET /read
--- response_headers
!X-Foo
--- response_body
Hello
=== TEST 10: set multi response content-type header (multiple times)
--- config
location /read {
content_by_lua '
ngx.header["X-Foo"] = {"a", "bc"}
ngx.header["X-Foo"] = {"a", "abc"}
ngx.say("Hello")
';
}
--- request
GET /read
--- raw_response_headers_like chomp
X-Foo: a\r\n.*?X-Foo: abc$
--- response_body
Hello