Initial Commit
This commit is contained in:
393
headers-more-nginx-module-0.32/t/bug.t
Normal file
393
headers-more-nginx-module-0.32/t/bug.t
Normal file
@@ -0,0 +1,393 @@
|
||||
# vi:filetype=
|
||||
|
||||
use Test::Nginx::Socket; # 'no_plan';
|
||||
|
||||
repeat_each(2);
|
||||
|
||||
plan tests => 53 * repeat_each();
|
||||
|
||||
no_diff;
|
||||
|
||||
run_tests();
|
||||
|
||||
__DATA__
|
||||
|
||||
=== TEST 1: set Server
|
||||
--- config
|
||||
#more_set_headers 'Last-Modified: x';
|
||||
more_clear_headers 'Last-Modified';
|
||||
--- request
|
||||
GET /index.html
|
||||
--- response_headers
|
||||
! Last-Modified
|
||||
--- response_body_like: It works!
|
||||
|
||||
|
||||
|
||||
=== TEST 2: variables in the Ranges header
|
||||
--- config
|
||||
location /index.html {
|
||||
set $rfrom 1;
|
||||
set $rto 3;
|
||||
more_set_input_headers 'Range: bytes=$rfrom - $rto';
|
||||
#more_set_input_headers 'Range: bytes=1 - 3';
|
||||
#echo $http_range;
|
||||
}
|
||||
--- request
|
||||
GET /index.html
|
||||
--- error_code: 206
|
||||
--- response_body chomp
|
||||
htm
|
||||
|
||||
|
||||
|
||||
=== TEST 3: mime type overriding (inlined types)
|
||||
--- config
|
||||
more_clear_headers 'X-Powered-By' 'X-Runtime' 'ETag';
|
||||
|
||||
types {
|
||||
text/html html htm shtml;
|
||||
text/css css;
|
||||
}
|
||||
--- user_files
|
||||
>>> a.css
|
||||
hello
|
||||
--- request
|
||||
GET /a.css
|
||||
--- error_code: 200
|
||||
--- response_headers
|
||||
Content-Type: text/css
|
||||
--- response_body
|
||||
hello
|
||||
|
||||
|
||||
|
||||
=== TEST 4: mime type overriding (included types file)
|
||||
--- config
|
||||
more_clear_headers 'X-Powered-By' 'X-Runtime' 'ETag';
|
||||
include mime.types;
|
||||
--- user_files
|
||||
>>> a.css
|
||||
hello
|
||||
>>> ../conf/mime.types
|
||||
types {
|
||||
text/html html htm shtml;
|
||||
text/css css;
|
||||
}
|
||||
--- request
|
||||
GET /a.css
|
||||
--- error_code: 200
|
||||
--- response_headers
|
||||
Content-Type: text/css
|
||||
--- response_body
|
||||
hello
|
||||
|
||||
|
||||
|
||||
=== TEST 5: empty variable as the header value
|
||||
--- config
|
||||
location /foo {
|
||||
more_set_headers 'X-Foo: $arg_foo';
|
||||
echo hi;
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_headers
|
||||
! X-Foo
|
||||
--- response_body
|
||||
hi
|
||||
|
||||
|
||||
|
||||
=== TEST 6: range bug
|
||||
--- config
|
||||
location /index.html {
|
||||
more_clear_input_headers "Range*" ;
|
||||
more_clear_input_headers "Content-Range*" ;
|
||||
|
||||
more_set_input_headers 'Range: bytes=1-5';
|
||||
more_set_headers 'Content-Range: bytes 1-5/1000';
|
||||
}
|
||||
--- request
|
||||
GET /index.html
|
||||
--- more_headers
|
||||
Range: bytes=1-3
|
||||
--- raw_response_headers_like: Content-Range: bytes 1-5/1000$
|
||||
--- response_body chop
|
||||
html>
|
||||
--- error_code: 206
|
||||
--- SKIP
|
||||
|
||||
|
||||
|
||||
=== TEST 7: Allow-Ranges
|
||||
--- config
|
||||
location /index.html {
|
||||
more_clear_headers 'Accept-Ranges';
|
||||
}
|
||||
--- request
|
||||
GET /index.html
|
||||
--- response_headers
|
||||
! Accept-Ranges
|
||||
--- response_body_like: It works
|
||||
|
||||
|
||||
|
||||
=== TEST 8: clear hand-written Allow-Ranges headers
|
||||
--- config
|
||||
location /index.html {
|
||||
more_set_headers 'Accept-Ranges: bytes';
|
||||
more_clear_headers 'Accept-Ranges';
|
||||
}
|
||||
--- request
|
||||
GET /index.html
|
||||
--- response_headers
|
||||
! Accept-Ranges
|
||||
--- response_body_like: It works
|
||||
|
||||
|
||||
|
||||
=== TEST 9: clear first, then add
|
||||
--- config
|
||||
location /bug {
|
||||
more_clear_headers 'Foo';
|
||||
more_set_headers 'Foo: a';
|
||||
echo hello;
|
||||
}
|
||||
--- request
|
||||
GET /bug
|
||||
--- raw_response_headers_like eval
|
||||
".*Foo: a.*"
|
||||
--- response_body
|
||||
hello
|
||||
|
||||
|
||||
|
||||
=== TEST 10: first add, then clear, then add again
|
||||
--- config
|
||||
location /bug {
|
||||
more_set_headers 'Foo: a';
|
||||
more_clear_headers 'Foo';
|
||||
more_set_headers 'Foo: b';
|
||||
echo hello;
|
||||
}
|
||||
--- request
|
||||
GET /bug
|
||||
--- raw_response_headers_like eval
|
||||
".*Foo: b.*"
|
||||
--- response_body
|
||||
hello
|
||||
|
||||
|
||||
|
||||
=== TEST 11: override charset
|
||||
--- config
|
||||
location /foo {
|
||||
charset iso-8859-1;
|
||||
default_type "text/html";
|
||||
echo hiya;
|
||||
}
|
||||
|
||||
location /bug {
|
||||
more_set_headers "Content-Type: text/html; charset=UTF-8";
|
||||
proxy_pass http://127.0.0.1:$server_port/foo;
|
||||
}
|
||||
--- request
|
||||
GET /bug
|
||||
--- response_body
|
||||
hiya
|
||||
--- response_headers
|
||||
Content-Type: text/html; charset=UTF-8
|
||||
|
||||
|
||||
|
||||
=== TEST 12: set multi-value header to a single value
|
||||
--- config
|
||||
location /main {
|
||||
set $footer '';
|
||||
proxy_pass http://127.0.0.1:$server_port/foo;
|
||||
more_set_headers 'Foo: b';
|
||||
header_filter_by_lua '
|
||||
ngx.var.footer = ngx.header.Foo
|
||||
';
|
||||
echo_after_body $footer;
|
||||
}
|
||||
location /foo {
|
||||
echo foo;
|
||||
add_header Foo a;
|
||||
add_header Foo c;
|
||||
}
|
||||
--- request
|
||||
GET /main
|
||||
--- response_headers
|
||||
Foo: b
|
||||
--- response_body
|
||||
foo
|
||||
b
|
||||
|
||||
|
||||
|
||||
=== TEST 13: set multi values to cache-control and override it with multiple values (to reproduce a bug)
|
||||
--- config
|
||||
location /lua {
|
||||
content_by_lua '
|
||||
ngx.header.cache_control = { "private", "no-store", "foo", "bar", "baz" }
|
||||
ngx.send_headers()
|
||||
ngx.say("Cache-Control: ", ngx.var.sent_http_cache_control)
|
||||
';
|
||||
more_clear_headers Cache-Control;
|
||||
add_header Cache-Control "blah";
|
||||
}
|
||||
--- request
|
||||
GET /lua
|
||||
--- response_headers
|
||||
Cache-Control: blah
|
||||
--- response_body
|
||||
Cache-Control: blah
|
||||
|
||||
|
||||
|
||||
=== TEST 14: set 20+ headers
|
||||
--- config
|
||||
location /test {
|
||||
more_clear_input_headers "Authorization";
|
||||
echo $http_a1;
|
||||
echo $http_authorization;
|
||||
echo $http_a2;
|
||||
echo $http_a3;
|
||||
echo $http_a23;
|
||||
echo $http_a24;
|
||||
echo $http_a25;
|
||||
}
|
||||
--- request
|
||||
GET /test
|
||||
--- more_headers eval
|
||||
my $i = 1;
|
||||
my $s;
|
||||
while ($i <= 25) {
|
||||
$s .= "A$i: $i\n";
|
||||
if ($i == 22) {
|
||||
$s .= "Authorization: blah\n";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
#warn $s;
|
||||
$s
|
||||
--- response_body
|
||||
1
|
||||
|
||||
2
|
||||
3
|
||||
23
|
||||
24
|
||||
25
|
||||
|
||||
|
||||
|
||||
=== TEST 15: github #20: segfault caused by the nasty optimization in the nginx core (set)
|
||||
--- config
|
||||
location = /t/ {
|
||||
more_set_headers "Foo: 1";
|
||||
proxy_pass http://127.0.0.1:$server_port;
|
||||
}
|
||||
--- request
|
||||
GET /t
|
||||
--- more_headers
|
||||
Foo: bar
|
||||
Bah: baz
|
||||
--- response_body_like: 301 Moved Permanently
|
||||
--- error_code: 301
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 16: github #20: segfault caused by the nasty optimization in the nginx core (clear)
|
||||
--- config
|
||||
location = /t/ {
|
||||
more_clear_headers Foo;
|
||||
proxy_pass http://127.0.0.1:$server_port;
|
||||
}
|
||||
--- request
|
||||
GET /t
|
||||
--- more_headers
|
||||
Foo: bar
|
||||
Bah: baz
|
||||
--- response_body_like: 301 Moved Permanently
|
||||
--- error_code: 301
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 17: Content-Type response headers with a charset param (correct -t values)
|
||||
--- config
|
||||
location = /t {
|
||||
more_set_headers -t 'text/html' 'X-Foo: Bar';
|
||||
proxy_pass http://127.0.0.1:$server_port/fake;
|
||||
}
|
||||
|
||||
location = /fake {
|
||||
default_type text/html;
|
||||
charset utf-8;
|
||||
echo ok;
|
||||
}
|
||||
--- request
|
||||
GET /t
|
||||
--- response_headers
|
||||
X-Foo: Bar
|
||||
--- response_body
|
||||
ok
|
||||
|
||||
|
||||
|
||||
=== TEST 18: Content-Type response headers with a charset param (WRONG -t values)
|
||||
--- config
|
||||
location = /t {
|
||||
more_set_headers -t 'text/html; charset=utf-8' 'X-Foo: Bar';
|
||||
proxy_pass http://127.0.0.1:$server_port/fake;
|
||||
}
|
||||
|
||||
location = /fake {
|
||||
default_type text/html;
|
||||
charset utf-8;
|
||||
echo ok;
|
||||
}
|
||||
--- request
|
||||
GET /t
|
||||
--- response_headers
|
||||
X-Foo: Bar
|
||||
--- response_body
|
||||
ok
|
||||
|
||||
|
||||
|
||||
=== TEST 19: for bad requests (bad request method letter case)
|
||||
--- config
|
||||
error_page 400 = /err;
|
||||
|
||||
location = /err {
|
||||
more_set_input_headers "Foo: bar";
|
||||
echo ok;
|
||||
}
|
||||
--- raw_request
|
||||
GeT / HTTP/1.1
|
||||
--- response_body
|
||||
ok
|
||||
--- no_check_leak
|
||||
|
||||
|
||||
|
||||
=== TEST 20: for bad requests (bad request method names)
|
||||
--- config
|
||||
error_page 400 = /err;
|
||||
|
||||
location = /err {
|
||||
more_set_input_headers "Foo: bar";
|
||||
echo ok;
|
||||
}
|
||||
--- raw_request
|
||||
GET x HTTP/1.1
|
||||
--- response_body
|
||||
ok
|
||||
--- no_check_leak
|
||||
339
headers-more-nginx-module-0.32/t/builtin.t
Normal file
339
headers-more-nginx-module-0.32/t/builtin.t
Normal file
@@ -0,0 +1,339 @@
|
||||
# vi:filetype=
|
||||
|
||||
use lib 'lib';
|
||||
use Test::Nginx::Socket; # 'no_plan';
|
||||
|
||||
plan tests => 60;
|
||||
|
||||
no_diff;
|
||||
|
||||
run_tests();
|
||||
|
||||
__DATA__
|
||||
|
||||
=== TEST 1: set Server
|
||||
--- config
|
||||
location /foo {
|
||||
echo hi;
|
||||
more_set_headers 'Server: Foo';
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_headers
|
||||
Server: Foo
|
||||
--- response_body
|
||||
hi
|
||||
|
||||
|
||||
|
||||
=== TEST 2: clear Server
|
||||
--- config
|
||||
location /foo {
|
||||
echo hi;
|
||||
more_clear_headers 'Server: ';
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_headers
|
||||
! Server
|
||||
--- response_body
|
||||
hi
|
||||
|
||||
|
||||
|
||||
=== TEST 3: set Content-Type
|
||||
--- config
|
||||
location /foo {
|
||||
default_type 'text/plan';
|
||||
more_set_headers 'Content-Type: text/css';
|
||||
echo hi;
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_headers
|
||||
Content-Type: text/css
|
||||
--- response_body
|
||||
hi
|
||||
|
||||
|
||||
|
||||
=== TEST 4: set Content-Type
|
||||
--- config
|
||||
location /foo {
|
||||
default_type 'text/plan';
|
||||
more_set_headers 'Content-Type: text/css';
|
||||
return 404;
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_headers
|
||||
Content-Type: text/css
|
||||
--- response_body_like: 404 Not Found
|
||||
--- error_code: 404
|
||||
|
||||
|
||||
|
||||
=== TEST 5: clear Content-Type
|
||||
--- config
|
||||
location /foo {
|
||||
default_type 'text/plain';
|
||||
more_clear_headers 'Content-Type: ';
|
||||
return 404;
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_headers
|
||||
! Content-Type
|
||||
--- response_body_like: 404 Not Found
|
||||
--- error_code: 404
|
||||
|
||||
|
||||
|
||||
=== TEST 6: clear Content-Type (colon not required)
|
||||
--- config
|
||||
location /foo {
|
||||
default_type 'text/plain';
|
||||
more_set_headers 'Content-Type: Hello';
|
||||
more_clear_headers 'Content-Type';
|
||||
return 404;
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_headers
|
||||
! Content-Type
|
||||
--- response_body_like: 404 Not Found
|
||||
--- error_code: 404
|
||||
|
||||
|
||||
|
||||
=== TEST 7: clear Content-Type (value ignored)
|
||||
--- config
|
||||
location /foo {
|
||||
default_type 'text/plain';
|
||||
more_set_headers 'Content-Type: Hello';
|
||||
more_clear_headers 'Content-Type: blah';
|
||||
return 404;
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_headers
|
||||
! Content-Type
|
||||
--- response_body_like: 404 Not Found
|
||||
--- error_code: 404
|
||||
|
||||
|
||||
|
||||
=== TEST 8: clear Content-Type (case insensitive)
|
||||
--- config
|
||||
location /foo {
|
||||
default_type 'text/plain';
|
||||
more_set_headers 'Content-Type: Hello';
|
||||
more_clear_headers 'content-type: blah';
|
||||
return 404;
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_headers
|
||||
! Content-Type
|
||||
--- response_body_like: 404 Not Found
|
||||
--- error_code: 404
|
||||
|
||||
|
||||
|
||||
=== TEST 9: clear Content-Type using set empty
|
||||
--- config
|
||||
location /foo {
|
||||
default_type 'text/plain';
|
||||
more_set_headers 'Content-Type: Hello';
|
||||
more_set_headers 'content-type:';
|
||||
return 404;
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_headers
|
||||
! Content-Type
|
||||
--- response_body_like: 404 Not Found
|
||||
--- error_code: 404
|
||||
|
||||
|
||||
|
||||
=== TEST 10: clear Content-Type using setting key only
|
||||
--- config
|
||||
location /foo {
|
||||
default_type 'text/plain';
|
||||
more_set_headers 'Content-Type: Hello';
|
||||
more_set_headers 'content-type';
|
||||
return 404;
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_headers
|
||||
! Content-Type
|
||||
--- response_body_like: 404 Not Found
|
||||
--- error_code: 404
|
||||
|
||||
|
||||
|
||||
=== TEST 11: set content-length
|
||||
--- config
|
||||
location /len {
|
||||
more_set_headers 'Content-Length: 2';
|
||||
echo hello;
|
||||
}
|
||||
--- request
|
||||
GET /len
|
||||
--- response_headers
|
||||
Content-Length: 2
|
||||
--- response_body chop
|
||||
he
|
||||
|
||||
|
||||
|
||||
=== TEST 12: set content-length multiple times
|
||||
--- config
|
||||
location /len {
|
||||
more_set_headers 'Content-Length: 2';
|
||||
more_set_headers 'Content-Length: 4';
|
||||
echo hello;
|
||||
}
|
||||
--- request
|
||||
GET /len
|
||||
--- response_headers
|
||||
Content-Length: 4
|
||||
--- response_body chop
|
||||
hell
|
||||
|
||||
|
||||
|
||||
=== TEST 13: clear content-length
|
||||
--- config
|
||||
location /len {
|
||||
more_set_headers 'Content-Length: 4';
|
||||
more_set_headers 'Content-Length:';
|
||||
echo hello;
|
||||
}
|
||||
--- request
|
||||
GET /len
|
||||
--- response_headers
|
||||
! Content-Length
|
||||
--- response_body
|
||||
hello
|
||||
|
||||
|
||||
|
||||
=== TEST 14: clear content-length (another way)
|
||||
--- config
|
||||
location /len {
|
||||
more_set_headers 'Content-Length: 4';
|
||||
more_clear_headers 'Content-Length';
|
||||
echo hello;
|
||||
}
|
||||
--- request
|
||||
GET /len
|
||||
--- response_headers
|
||||
! Content-Length
|
||||
--- response_body
|
||||
hello
|
||||
|
||||
|
||||
|
||||
=== TEST 15: clear content-type
|
||||
--- config
|
||||
location /len {
|
||||
default_type 'text/plain';
|
||||
more_set_headers 'Content-Type:';
|
||||
echo hello;
|
||||
}
|
||||
--- request
|
||||
GET /len
|
||||
--- response_headers
|
||||
! Content-Type
|
||||
--- response_body
|
||||
hello
|
||||
|
||||
|
||||
|
||||
=== TEST 16: clear content-type (the other way)
|
||||
--- config
|
||||
location /len {
|
||||
default_type 'text/plain';
|
||||
more_clear_headers 'Content-Type:';
|
||||
echo hello;
|
||||
}
|
||||
--- request
|
||||
GET /len
|
||||
--- response_headers
|
||||
! Content-Type
|
||||
--- response_body
|
||||
hello
|
||||
|
||||
|
||||
|
||||
=== TEST 17: set Charset
|
||||
--- config
|
||||
location /len {
|
||||
default_type 'text/plain';
|
||||
more_set_headers 'Charset: gbk';
|
||||
echo hello;
|
||||
}
|
||||
--- request
|
||||
GET /len
|
||||
--- response_headers
|
||||
Charset: gbk
|
||||
--- response_body
|
||||
hello
|
||||
|
||||
|
||||
|
||||
=== TEST 18: clear Charset
|
||||
--- config
|
||||
location /len {
|
||||
default_type 'text/plain';
|
||||
more_set_headers 'Charset: gbk';
|
||||
more_clear_headers 'Charset';
|
||||
echo hello;
|
||||
}
|
||||
--- request
|
||||
GET /len
|
||||
--- response_headers
|
||||
! Charset
|
||||
--- response_body
|
||||
hello
|
||||
|
||||
|
||||
|
||||
=== TEST 19: clear Charset (the other way: using set)
|
||||
--- config
|
||||
location /len {
|
||||
default_type 'text/plain';
|
||||
more_set_headers 'Charset: gbk';
|
||||
more_set_headers 'Charset: ';
|
||||
echo hello;
|
||||
}
|
||||
--- request
|
||||
GET /len
|
||||
--- response_headers
|
||||
! Charset
|
||||
--- response_body
|
||||
hello
|
||||
|
||||
|
||||
|
||||
=== TEST 20: set Vary
|
||||
--- config
|
||||
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;
|
||||
}
|
||||
--- request
|
||||
GET /len
|
||||
--- response_headers
|
||||
Vary: hello
|
||||
--- response_body
|
||||
hello
|
||||
|
||||
36
headers-more-nginx-module-0.32/t/eval.t
Normal file
36
headers-more-nginx-module-0.32/t/eval.t
Normal file
@@ -0,0 +1,36 @@
|
||||
# vi:filetype=
|
||||
|
||||
use lib 'lib';
|
||||
use Test::Nginx::Socket; # 'no_plan';
|
||||
|
||||
repeat_each(3);
|
||||
|
||||
plan tests => repeat_each() * 2 * blocks();
|
||||
|
||||
#no_long_string();
|
||||
#no_diff;
|
||||
|
||||
run_tests();
|
||||
|
||||
__DATA__
|
||||
|
||||
=== TEST 1: set request header at client side
|
||||
--- config
|
||||
location /foo {
|
||||
eval_subrequest_in_memory off;
|
||||
eval_override_content_type text/plain;
|
||||
eval $res {
|
||||
echo -n 1;
|
||||
}
|
||||
#echo "[$res]";
|
||||
if ($res = '1') {
|
||||
more_set_input_headers 'Foo: Bar';
|
||||
echo "OK";
|
||||
break;
|
||||
}
|
||||
echo "NOT OK";
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_body
|
||||
OK
|
||||
138
headers-more-nginx-module-0.32/t/input-conn.t
Normal file
138
headers-more-nginx-module-0.32/t/input-conn.t
Normal file
@@ -0,0 +1,138 @@
|
||||
# vim:set ft= ts=4 sw=4 et fdm=marker:
|
||||
|
||||
use lib 'lib';
|
||||
use Test::Nginx::Socket;
|
||||
|
||||
#worker_connections(1014);
|
||||
#master_process_enabled(1);
|
||||
#log_level('warn');
|
||||
|
||||
repeat_each(2);
|
||||
|
||||
plan tests => repeat_each() * (4 * blocks());
|
||||
|
||||
#no_diff();
|
||||
no_long_string();
|
||||
|
||||
run_tests();
|
||||
|
||||
__DATA__
|
||||
|
||||
=== TEST 1: clear the Connection req header
|
||||
--- config
|
||||
location /req-header {
|
||||
more_clear_input_headers Connection;
|
||||
echo "connection: $http_connection";
|
||||
}
|
||||
--- request
|
||||
GET /req-header
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: conn type: %d\n", $r->headers_in->connection_type)
|
||||
}
|
||||
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: conn type: %d\n", $r->headers_in->connection_type)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: conn type: 1
|
||||
content: conn type: 0
|
||||
|
||||
--- response_body
|
||||
connection:
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 2: set custom Connection req header (close)
|
||||
--- config
|
||||
location /req-header {
|
||||
more_set_input_headers "Connection: CLOSE";
|
||||
echo "connection: $http_connection";
|
||||
}
|
||||
--- request
|
||||
GET /req-header
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: conn type: %d\n", $r->headers_in->connection_type)
|
||||
}
|
||||
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: conn type: %d\n", $r->headers_in->connection_type)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: conn type: 1
|
||||
content: conn type: 1
|
||||
|
||||
--- response_body
|
||||
connection: CLOSE
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 3: set custom Connection req header (keep-alive)
|
||||
--- config
|
||||
location /req-header {
|
||||
more_set_input_headers "Connection: keep-alive";
|
||||
echo "connection: $http_connection";
|
||||
}
|
||||
--- request
|
||||
GET /req-header
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: conn type: %d\n", $r->headers_in->connection_type)
|
||||
}
|
||||
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: conn type: %d\n", $r->headers_in->connection_type)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: conn type: 1
|
||||
content: conn type: 2
|
||||
|
||||
--- response_body
|
||||
connection: keep-alive
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 4: set custom Connection req header (bad)
|
||||
--- config
|
||||
location /req-header {
|
||||
more_set_input_headers "Connection: bad";
|
||||
echo "connection: $http_connection";
|
||||
}
|
||||
--- request
|
||||
GET /req-header
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: conn type: %d\n", $r->headers_in->connection_type)
|
||||
}
|
||||
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: conn type: %d\n", $r->headers_in->connection_type)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: conn type: 1
|
||||
content: conn type: 0
|
||||
|
||||
--- response_body
|
||||
connection: bad
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
183
headers-more-nginx-module-0.32/t/input-cookie.t
Normal file
183
headers-more-nginx-module-0.32/t/input-cookie.t
Normal file
@@ -0,0 +1,183 @@
|
||||
# vim:set ft= ts=4 sw=4 et fdm=marker:
|
||||
|
||||
use lib 'lib';
|
||||
use Test::Nginx::Socket;
|
||||
|
||||
#worker_connections(1014);
|
||||
#master_process_enabled(1);
|
||||
#log_level('warn');
|
||||
|
||||
repeat_each(2);
|
||||
|
||||
plan tests => repeat_each() * (4 * blocks());
|
||||
|
||||
#no_diff();
|
||||
no_long_string();
|
||||
|
||||
run_tests();
|
||||
|
||||
__DATA__
|
||||
|
||||
=== TEST 1: clear cookie (with existing cookies)
|
||||
--- config
|
||||
location /t {
|
||||
more_clear_input_headers Cookie;
|
||||
echo "Cookie foo: $cookie_foo";
|
||||
echo "Cookie baz: $cookie_baz";
|
||||
echo "Cookie: $http_cookie";
|
||||
}
|
||||
--- request
|
||||
GET /t
|
||||
--- more_headers
|
||||
Cookie: foo=bar
|
||||
Cookie: baz=blah
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: cookies: %d\n", $r->headers_in->cookies->nelts)
|
||||
}
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: cookies: %d\n", $r->headers_in->cookies->nelts)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: cookies: 2
|
||||
content: cookies: 0
|
||||
|
||||
--- response_body
|
||||
Cookie foo:
|
||||
Cookie baz:
|
||||
Cookie:
|
||||
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 2: clear cookie (without existing cookies)
|
||||
--- config
|
||||
location /t {
|
||||
more_clear_input_headers Cookie;
|
||||
echo "Cookie foo: $cookie_foo";
|
||||
echo "Cookie baz: $cookie_baz";
|
||||
echo "Cookie: $http_cookie";
|
||||
}
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: cookies: %d\n", $r->headers_in->cookies->nelts)
|
||||
}
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: cookies: %d\n", $r->headers_in->cookies->nelts)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: cookies: 0
|
||||
content: cookies: 0
|
||||
|
||||
--- response_body
|
||||
Cookie foo:
|
||||
Cookie baz:
|
||||
Cookie:
|
||||
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 3: set one custom cookie (with existing cookies)
|
||||
--- config
|
||||
location /t {
|
||||
more_set_input_headers "Cookie: boo=123";
|
||||
echo "Cookie foo: $cookie_foo";
|
||||
echo "Cookie baz: $cookie_baz";
|
||||
echo "Cookie boo: $cookie_boo";
|
||||
echo "Cookie: $http_cookie";
|
||||
}
|
||||
--- request
|
||||
GET /t
|
||||
--- more_headers
|
||||
Cookie: foo=bar
|
||||
Cookie: baz=blah
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: cookies: %d\n", $r->headers_in->cookies->nelts)
|
||||
}
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: cookies: %d\n", $r->headers_in->cookies->nelts)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: cookies: 2
|
||||
content: cookies: 1
|
||||
|
||||
--- response_body
|
||||
Cookie foo:
|
||||
Cookie baz:
|
||||
Cookie boo: 123
|
||||
Cookie: boo=123
|
||||
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 4: set one custom cookie (without existing cookies)
|
||||
--- config
|
||||
location /t {
|
||||
more_set_input_headers "Cookie: boo=123";
|
||||
echo "Cookie foo: $cookie_foo";
|
||||
echo "Cookie baz: $cookie_baz";
|
||||
echo "Cookie boo: $cookie_boo";
|
||||
echo "Cookie: $http_cookie";
|
||||
}
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: cookies: %d\n", $r->headers_in->cookies->nelts)
|
||||
}
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: cookies: %d\n", $r->headers_in->cookies->nelts)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: cookies: 0
|
||||
content: cookies: 1
|
||||
|
||||
--- response_body
|
||||
Cookie foo:
|
||||
Cookie baz:
|
||||
Cookie boo: 123
|
||||
Cookie: boo=123
|
||||
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 5: for bad requests causing segfaults when setting & getting multi-value headers
|
||||
--- config
|
||||
error_page 400 = /err;
|
||||
|
||||
location = /err {
|
||||
more_set_input_headers "Cookie: foo=bar";
|
||||
echo -n $cookie_foo;
|
||||
echo ok;
|
||||
}
|
||||
--- raw_request
|
||||
GeT / HTTP/1.1
|
||||
--- response_body
|
||||
ok
|
||||
--- no_error_log
|
||||
[error]
|
||||
[alert]
|
||||
--- no_check_leak
|
||||
629
headers-more-nginx-module-0.32/t/input-ua.t
Normal file
629
headers-more-nginx-module-0.32/t/input-ua.t
Normal file
@@ -0,0 +1,629 @@
|
||||
# vim:set ft= ts=4 sw=4 et fdm=marker:
|
||||
|
||||
use lib 'lib';
|
||||
use Test::Nginx::Socket;
|
||||
|
||||
#worker_connections(1014);
|
||||
#master_process_enabled(1);
|
||||
#log_level('warn');
|
||||
|
||||
repeat_each(2);
|
||||
|
||||
plan tests => repeat_each() * (4 * blocks());
|
||||
|
||||
#no_diff();
|
||||
no_long_string();
|
||||
|
||||
run_tests();
|
||||
|
||||
__DATA__
|
||||
|
||||
=== TEST 1: clear Opera user-agent
|
||||
--- config
|
||||
location /t {
|
||||
more_clear_input_headers User-Agent;
|
||||
echo "User-Agent: $http_user_agent";
|
||||
}
|
||||
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- more_headers
|
||||
User-Agent: Opera/9.80 (Macintosh; Intel Mac OS X 10.7.4; U; en) Presto/2.10.229 Version/11.62
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: opera: %d\n", $r->headers_in->opera)
|
||||
}
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: opera: %d\n", $r->headers_in->opera)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: opera: 1
|
||||
content: opera: 0
|
||||
|
||||
--- response_body
|
||||
User-Agent:
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 2: clear MSIE 4 user-agent
|
||||
--- config
|
||||
location /t {
|
||||
more_clear_input_headers User-Agent;
|
||||
echo "User-Agent: $http_user_agent";
|
||||
}
|
||||
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- more_headers
|
||||
User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT 5.0)
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: msie=%d msie6=%d\n",
|
||||
$r->headers_in->msie,
|
||||
$r->headers_in->msie6)
|
||||
}
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: msie=%d msie6=%d\n",
|
||||
$r->headers_in->msie,
|
||||
$r->headers_in->msie6)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: msie=1 msie6=1
|
||||
content: msie=0 msie6=0
|
||||
|
||||
--- response_body
|
||||
User-Agent:
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 3: set custom MSIE 4 user-agent
|
||||
--- config
|
||||
location /t {
|
||||
more_set_input_headers "User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT 5.0)";
|
||||
echo "User-Agent: $http_user_agent";
|
||||
}
|
||||
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: msie=%d msie6=%d\n",
|
||||
$r->headers_in->msie,
|
||||
$r->headers_in->msie6)
|
||||
}
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: msie=%d msie6=%d\n",
|
||||
$r->headers_in->msie,
|
||||
$r->headers_in->msie6)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: msie=0 msie6=0
|
||||
content: msie=1 msie6=1
|
||||
|
||||
--- response_body
|
||||
User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT 5.0)
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 4: clear MSIE 5 user-agent
|
||||
--- config
|
||||
location /t {
|
||||
more_clear_input_headers User-Agent;
|
||||
echo "User-Agent: $http_user_agent";
|
||||
}
|
||||
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- more_headers
|
||||
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows 95; MSIECrawler)
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: msie=%d msie6=%d\n",
|
||||
$r->headers_in->msie,
|
||||
$r->headers_in->msie6)
|
||||
}
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: msie=%d msie6=%d\n",
|
||||
$r->headers_in->msie,
|
||||
$r->headers_in->msie6)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: msie=1 msie6=1
|
||||
content: msie=0 msie6=0
|
||||
|
||||
--- response_body
|
||||
User-Agent:
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 5: set custom MSIE 5 user-agent
|
||||
--- config
|
||||
location /t {
|
||||
more_set_input_headers "User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows 95; MSIECrawler)";
|
||||
echo "User-Agent: $http_user_agent";
|
||||
}
|
||||
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: msie=%d msie6=%d\n",
|
||||
$r->headers_in->msie,
|
||||
$r->headers_in->msie6)
|
||||
}
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: msie=%d msie6=%d\n",
|
||||
$r->headers_in->msie,
|
||||
$r->headers_in->msie6)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: msie=0 msie6=0
|
||||
content: msie=1 msie6=1
|
||||
|
||||
--- response_body
|
||||
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows 95; MSIECrawler)
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 6: clear MSIE 6 (without SV1) user-agent
|
||||
--- config
|
||||
location /t {
|
||||
more_clear_input_headers User-Agent;
|
||||
echo "User-Agent: $http_user_agent";
|
||||
}
|
||||
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- more_headers
|
||||
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Google Wireless Transcoder;)
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: msie=%d msie6=%d\n",
|
||||
$r->headers_in->msie,
|
||||
$r->headers_in->msie6)
|
||||
}
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: msie=%d msie6=%d\n",
|
||||
$r->headers_in->msie,
|
||||
$r->headers_in->msie6)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: msie=1 msie6=1
|
||||
content: msie=0 msie6=0
|
||||
|
||||
--- response_body
|
||||
User-Agent:
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 7: set custom MSIE 6 (without SV1) user-agent
|
||||
--- config
|
||||
location /t {
|
||||
more_set_input_headers "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Google Wireless Transcoder;)";
|
||||
echo "User-Agent: $http_user_agent";
|
||||
}
|
||||
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: msie=%d msie6=%d\n",
|
||||
$r->headers_in->msie,
|
||||
$r->headers_in->msie6)
|
||||
}
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: msie=%d msie6=%d\n",
|
||||
$r->headers_in->msie,
|
||||
$r->headers_in->msie6)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: msie=0 msie6=0
|
||||
content: msie=1 msie6=1
|
||||
|
||||
--- response_body
|
||||
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Google Wireless Transcoder;)
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 8: clear MSIE 6 (with SV1) user-agent
|
||||
--- config
|
||||
location /t {
|
||||
more_clear_input_headers User-Agent;
|
||||
echo "User-Agent: $http_user_agent";
|
||||
}
|
||||
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- more_headers
|
||||
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.1)
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: msie=%d msie6=%d\n",
|
||||
$r->headers_in->msie,
|
||||
$r->headers_in->msie6)
|
||||
}
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: msie=%d msie6=%d\n",
|
||||
$r->headers_in->msie,
|
||||
$r->headers_in->msie6)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: msie=1 msie6=0
|
||||
content: msie=0 msie6=0
|
||||
|
||||
--- response_body
|
||||
User-Agent:
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 9: set custom MSIE 6 (with SV1) user-agent
|
||||
--- config
|
||||
location /t {
|
||||
more_set_input_headers "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.1)";
|
||||
echo "User-Agent: $http_user_agent";
|
||||
}
|
||||
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: msie=%d msie6=%d\n",
|
||||
$r->headers_in->msie,
|
||||
$r->headers_in->msie6)
|
||||
}
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: msie=%d msie6=%d\n",
|
||||
$r->headers_in->msie,
|
||||
$r->headers_in->msie6)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: msie=0 msie6=0
|
||||
content: msie=1 msie6=0
|
||||
|
||||
--- response_body
|
||||
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.1)
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 10: set custom MSIE 7 user-agent
|
||||
--- config
|
||||
location /t {
|
||||
more_set_input_headers "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; winfx; .NET CLR 1.1.4322; .NET CLR 2.0.50727; Zune 2.0)";
|
||||
echo "User-Agent: $http_user_agent";
|
||||
}
|
||||
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: msie=%d msie6=%d\n",
|
||||
$r->headers_in->msie,
|
||||
$r->headers_in->msie6)
|
||||
}
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: msie=%d msie6=%d\n",
|
||||
$r->headers_in->msie,
|
||||
$r->headers_in->msie6)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: msie=0 msie6=0
|
||||
content: msie=1 msie6=0
|
||||
|
||||
--- response_body
|
||||
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; winfx; .NET CLR 1.1.4322; .NET CLR 2.0.50727; Zune 2.0)
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 11: clear Gecko user-agent
|
||||
--- config
|
||||
location /t {
|
||||
more_clear_input_headers User-Agent;
|
||||
echo "User-Agent: $http_user_agent";
|
||||
}
|
||||
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- more_headers
|
||||
User-Agent: Mozilla/5.0 (Android; Mobile; rv:13.0) Gecko/13.0 Firefox/13.0
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: gecko: %d\n", $r->headers_in->gecko)
|
||||
}
|
||||
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: gecko: %d\n", $r->headers_in->gecko)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: gecko: 1
|
||||
content: gecko: 0
|
||||
|
||||
--- response_body
|
||||
User-Agent:
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 12: set custom Gecko user-agent
|
||||
--- config
|
||||
location /t {
|
||||
more_set_input_headers "User-Agent: Mozilla/5.0 (Android; Mobile; rv:13.0) Gecko/13.0 Firefox/13.0";
|
||||
echo "User-Agent: $http_user_agent";
|
||||
}
|
||||
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: gecko: %d\n", $r->headers_in->gecko)
|
||||
}
|
||||
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: gecko: %d\n", $r->headers_in->gecko)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: gecko: 0
|
||||
content: gecko: 1
|
||||
|
||||
--- response_body
|
||||
User-Agent: Mozilla/5.0 (Android; Mobile; rv:13.0) Gecko/13.0 Firefox/13.0
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 13: clear Chrome user-agent
|
||||
--- config
|
||||
location /t {
|
||||
more_clear_input_headers User-Agent;
|
||||
echo "User-Agent: $http_user_agent";
|
||||
}
|
||||
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- more_headers
|
||||
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.151 Safari/535.19
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: chrome: %d\n", $r->headers_in->chrome)
|
||||
}
|
||||
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: chrome: %d\n", $r->headers_in->chrome)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: chrome: 1
|
||||
content: chrome: 0
|
||||
|
||||
--- response_body
|
||||
User-Agent:
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 14: set custom Chrome user-agent
|
||||
--- config
|
||||
location /t {
|
||||
more_set_input_headers "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.151 Safari/535.19";
|
||||
echo "User-Agent: $http_user_agent";
|
||||
}
|
||||
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: chrome: %d\n", $r->headers_in->chrome)
|
||||
}
|
||||
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: chrome: %d\n", $r->headers_in->chrome)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: chrome: 0
|
||||
content: chrome: 1
|
||||
|
||||
--- response_body
|
||||
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.151 Safari/535.19
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 15: clear Safari (Mac OS X) user-agent
|
||||
--- config
|
||||
location /t {
|
||||
more_clear_input_headers User-Agent;
|
||||
echo "User-Agent: $http_user_agent";
|
||||
}
|
||||
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- more_headers
|
||||
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.2 (KHTML, like Gecko) Safari/125.8
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: safari: %d\n", $r->headers_in->safari)
|
||||
}
|
||||
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: safari: %d\n", $r->headers_in->safari)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: safari: 1
|
||||
content: safari: 0
|
||||
|
||||
--- response_body
|
||||
User-Agent:
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 16: set custom Safari user-agent
|
||||
--- config
|
||||
location /t {
|
||||
more_set_input_headers "User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.2 (KHTML, like Gecko) Safari/125.8";
|
||||
echo "User-Agent: $http_user_agent";
|
||||
}
|
||||
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: safari: %d\n", $r->headers_in->safari)
|
||||
}
|
||||
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: safari: %d\n", $r->headers_in->safari)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: safari: 0
|
||||
content: safari: 1
|
||||
|
||||
--- response_body
|
||||
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.2 (KHTML, like Gecko) Safari/125.8
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 17: clear Konqueror user-agent
|
||||
--- config
|
||||
location /t {
|
||||
more_clear_input_headers User-Agent;
|
||||
echo "User-Agent: $http_user_agent";
|
||||
}
|
||||
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- more_headers
|
||||
User-Agent: Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.10 (like Gecko) (Kubuntu)
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: konqueror: %d\n", $r->headers_in->konqueror)
|
||||
}
|
||||
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: konqueror: %d\n", $r->headers_in->konqueror)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: konqueror: 1
|
||||
content: konqueror: 0
|
||||
|
||||
--- response_body
|
||||
User-Agent:
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 18: set custom Konqueror user-agent
|
||||
--- config
|
||||
location /t {
|
||||
more_set_input_headers "User-Agent: Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.10 (like Gecko) (Kubuntu)";
|
||||
echo "User-Agent: $http_user_agent";
|
||||
}
|
||||
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- stap
|
||||
F(ngx_http_headers_more_exec_input_cmd) {
|
||||
printf("rewrite: konqueror: %d\n", $r->headers_in->konqueror)
|
||||
}
|
||||
|
||||
|
||||
F(ngx_http_core_content_phase) {
|
||||
printf("content: konqueror: %d\n", $r->headers_in->konqueror)
|
||||
}
|
||||
|
||||
--- stap_out
|
||||
rewrite: konqueror: 0
|
||||
content: konqueror: 1
|
||||
|
||||
--- response_body
|
||||
User-Agent: Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.10 (like Gecko) (Kubuntu)
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
1291
headers-more-nginx-module-0.32/t/input.t
Normal file
1291
headers-more-nginx-module-0.32/t/input.t
Normal file
File diff suppressed because it is too large
Load Diff
26
headers-more-nginx-module-0.32/t/phase.t
Normal file
26
headers-more-nginx-module-0.32/t/phase.t
Normal file
@@ -0,0 +1,26 @@
|
||||
# vi:filetype=perl
|
||||
|
||||
use lib 'lib';
|
||||
use Test::Nginx::Socket;
|
||||
|
||||
plan tests => 3;
|
||||
|
||||
no_diff;
|
||||
|
||||
run_tests();
|
||||
|
||||
__DATA__
|
||||
|
||||
=== TEST 1: simple set (1 arg)
|
||||
--- config
|
||||
location /foo {
|
||||
deny all;
|
||||
more_set_headers 'X-Foo: Blah';
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_headers
|
||||
X-Foo: Blah
|
||||
--- response_body_like: 403 Forbidden
|
||||
--- error_code: 403
|
||||
|
||||
568
headers-more-nginx-module-0.32/t/sanity.t
Normal file
568
headers-more-nginx-module-0.32/t/sanity.t
Normal file
@@ -0,0 +1,568 @@
|
||||
# vi:filetype=
|
||||
|
||||
use lib 'lib';
|
||||
use Test::Nginx::Socket;
|
||||
|
||||
repeat_each(2);
|
||||
|
||||
plan tests => repeat_each() * 113;
|
||||
|
||||
#master_on();
|
||||
#workers(2);
|
||||
log_level("warn");
|
||||
no_diff;
|
||||
|
||||
run_tests();
|
||||
|
||||
__DATA__
|
||||
|
||||
=== TEST 1: simple set (1 arg)
|
||||
--- config
|
||||
location /foo {
|
||||
echo hi;
|
||||
more_set_headers 'X-Foo: Blah';
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_headers
|
||||
X-Foo: Blah
|
||||
--- response_body
|
||||
hi
|
||||
|
||||
|
||||
|
||||
=== TEST 2: simple set (2 args)
|
||||
--- config
|
||||
location /foo {
|
||||
echo hi;
|
||||
more_set_headers 'X-Foo: Blah' 'X-Bar: hi';
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_headers
|
||||
X-Foo: Blah
|
||||
X-Bar: hi
|
||||
--- response_body
|
||||
hi
|
||||
|
||||
|
||||
|
||||
=== TEST 3: two sets in a single location
|
||||
--- config
|
||||
location /two {
|
||||
echo hi;
|
||||
more_set_headers 'X-Foo: Blah'
|
||||
more_set_headers 'X-Bar: hi';
|
||||
}
|
||||
--- request
|
||||
GET /two
|
||||
--- response_headers
|
||||
X-Foo: Blah
|
||||
X-Bar: hi
|
||||
--- response_body
|
||||
hi
|
||||
|
||||
|
||||
|
||||
=== TEST 4: two sets in a single location (for 404 too)
|
||||
--- config
|
||||
location /two {
|
||||
more_set_headers 'X-Foo: Blah'
|
||||
more_set_headers 'X-Bar: hi';
|
||||
return 404;
|
||||
}
|
||||
--- request
|
||||
GET /two
|
||||
--- response_headers
|
||||
X-Foo: Blah
|
||||
X-Bar: hi
|
||||
--- response_body_like: 404 Not Found
|
||||
--- error_code: 404
|
||||
|
||||
|
||||
|
||||
=== TEST 5: set a header then clears it (500)
|
||||
--- config
|
||||
location /two {
|
||||
more_set_headers 'X-Foo: Blah';
|
||||
more_set_headers 'X-Foo:';
|
||||
return 500;
|
||||
}
|
||||
--- request
|
||||
GET /two
|
||||
--- response_headers
|
||||
! X-Foo
|
||||
! X-Bar
|
||||
--- response_body_like: 500 Internal Server Error
|
||||
--- error_code: 500
|
||||
|
||||
|
||||
|
||||
=== TEST 6: set a header only when 500 (matched)
|
||||
--- config
|
||||
location /bad {
|
||||
more_set_headers -s 500 'X-Mine: Hiya';
|
||||
more_set_headers -s 404 'X-Yours: Blah';
|
||||
return 500;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
X-Mine: Hiya
|
||||
! X-Yours
|
||||
--- response_body_like: 500 Internal Server Error
|
||||
--- error_code: 500
|
||||
|
||||
|
||||
|
||||
=== TEST 7: set a header only when 500 (not matched with 200)
|
||||
--- config
|
||||
location /bad {
|
||||
more_set_headers -s 500 'X-Mine: Hiya';
|
||||
more_set_headers -s 404 'X-Yours: Blah';
|
||||
echo hello;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
! X-Mine
|
||||
! X-Yours
|
||||
--- response_body
|
||||
hello
|
||||
--- error_code: 200
|
||||
|
||||
|
||||
|
||||
=== TEST 8: set a header only when 500 (not matched with 404)
|
||||
--- config
|
||||
location /bad {
|
||||
more_set_headers -s 500 'X-Mine: Hiya';
|
||||
more_set_headers -s 404 'X-Yours: Blah';
|
||||
return 404;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
! X-Mine
|
||||
X-Yours: Blah
|
||||
--- response_body_like: 404 Not Found
|
||||
--- error_code: 404
|
||||
|
||||
|
||||
|
||||
=== TEST 9: more conditions
|
||||
--- config
|
||||
location /bad {
|
||||
more_set_headers -s '503 404' 'X-Mine: Hiya';
|
||||
more_set_headers -s ' 404 413 ' 'X-Yours: Blah';
|
||||
return 503;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
X-Mine: Hiya
|
||||
! X-Yours
|
||||
--- response_body_like: 503 Service
|
||||
--- error_code: 503
|
||||
|
||||
|
||||
|
||||
=== TEST 10: more conditions
|
||||
--- config
|
||||
location /bad {
|
||||
more_set_headers -s '503 404' 'X-Mine: Hiya';
|
||||
more_set_headers -s ' 404 413 ' 'X-Yours: Blah';
|
||||
return 404;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
X-Mine: Hiya
|
||||
X-Yours: Blah
|
||||
--- response_body_like: 404 Not Found
|
||||
--- error_code: 404
|
||||
|
||||
|
||||
|
||||
=== TEST 11: more conditions
|
||||
--- config
|
||||
location /bad {
|
||||
more_set_headers -s '503 404' 'X-Mine: Hiya';
|
||||
more_set_headers -s ' 404 413 ' 'X-Yours: Blah';
|
||||
return 413;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
! X-Mine
|
||||
X-Yours: Blah
|
||||
--- response_body_like: 413 Request Entity Too Large
|
||||
--- error_code: 413
|
||||
|
||||
|
||||
|
||||
=== TEST 12: simple -t
|
||||
--- config
|
||||
location /bad {
|
||||
default_type 'text/css';
|
||||
more_set_headers -t 'text/css' 'X-CSS: yes';
|
||||
echo hi;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
X-CSS: yes
|
||||
--- response_body
|
||||
hi
|
||||
|
||||
|
||||
|
||||
=== TEST 13: simple -t (not matched)
|
||||
--- config
|
||||
location /bad {
|
||||
default_type 'text/plain';
|
||||
more_set_headers -t 'text/css' 'X-CSS: yes';
|
||||
echo hi;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
! X-CSS
|
||||
--- response_body
|
||||
hi
|
||||
|
||||
|
||||
|
||||
=== TEST 14: multiple -t (not matched)
|
||||
--- config
|
||||
location /bad {
|
||||
default_type 'text/plain';
|
||||
more_set_headers -t 'text/javascript' -t 'text/css' 'X-CSS: yes';
|
||||
echo hi;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
! X-CSS
|
||||
--- response_body
|
||||
hi
|
||||
|
||||
|
||||
|
||||
=== TEST 15: multiple -t (matched)
|
||||
--- config
|
||||
location /bad {
|
||||
default_type 'text/plain';
|
||||
more_set_headers -t 'text/javascript' -t 'text/plain' 'X-CSS: yes';
|
||||
echo hi;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
X-CSS: yes
|
||||
--- response_body
|
||||
hi
|
||||
|
||||
|
||||
|
||||
=== TEST 16: multiple -t (matched)
|
||||
--- config
|
||||
location /bad {
|
||||
default_type 'text/javascript';
|
||||
more_set_headers -t 'text/javascript' -t 'text/plain' 'X-CSS: yes';
|
||||
echo hi;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
X-CSS: yes
|
||||
--- response_body
|
||||
hi
|
||||
|
||||
|
||||
|
||||
=== TEST 17: multiple -t (matched) with extra spaces
|
||||
--- config
|
||||
location /bad {
|
||||
default_type 'text/javascript';
|
||||
more_set_headers -t ' text/javascript ' -t 'text/plain' 'X-CSS: yes';
|
||||
echo hi;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
X-CSS: yes
|
||||
--- response_body
|
||||
hi
|
||||
|
||||
|
||||
|
||||
=== TEST 18: multiple -t merged
|
||||
--- config
|
||||
location /bad {
|
||||
default_type 'text/javascript';
|
||||
more_set_headers -t ' text/javascript text/plain' 'X-CSS: yes';
|
||||
echo hi;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
X-CSS: yes
|
||||
--- response_body
|
||||
hi
|
||||
|
||||
|
||||
|
||||
=== TEST 19: multiple -t merged (2)
|
||||
--- config
|
||||
location /bad {
|
||||
default_type 'text/plain';
|
||||
more_set_headers -t ' text/javascript text/plain' 'X-CSS: yes';
|
||||
echo hi;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
X-CSS: yes
|
||||
--- response_body
|
||||
hi
|
||||
|
||||
|
||||
|
||||
=== TEST 20: multiple -s option in a directive (not matched)
|
||||
--- config
|
||||
location /bad {
|
||||
more_set_headers -s 404 -s 500 'X-status: howdy';
|
||||
echo hi;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
! X-status
|
||||
--- response_body
|
||||
hi
|
||||
|
||||
|
||||
|
||||
=== TEST 21: multiple -s option in a directive (matched 404)
|
||||
--- config
|
||||
location /bad {
|
||||
more_set_headers -s 404 -s 500 'X-status: howdy';
|
||||
return 404;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
X-status: howdy
|
||||
--- response_body_like: 404 Not Found
|
||||
--- error_code: 404
|
||||
|
||||
|
||||
|
||||
=== TEST 22: multiple -s option in a directive (matched 500)
|
||||
--- config
|
||||
location /bad {
|
||||
more_set_headers -s 404 -s 500 'X-status: howdy';
|
||||
return 500;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
X-status: howdy
|
||||
--- response_body_like: 500 Internal Server Error
|
||||
--- error_code: 500
|
||||
|
||||
|
||||
|
||||
=== TEST 23: -s mixed with -t
|
||||
--- config
|
||||
location /bad {
|
||||
default_type 'text/html';
|
||||
more_set_headers -s 404 -s 200 -t 'text/html' 'X-status: howdy2';
|
||||
return 404;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
X-status: howdy2
|
||||
--- response_body_like: 404 Not Found
|
||||
--- error_code: 404
|
||||
|
||||
|
||||
|
||||
=== TEST 24: -s mixed with -t
|
||||
--- config
|
||||
location /bad {
|
||||
default_type 'text/html';
|
||||
more_set_headers -s 404 -s 200 -t 'text/plain' 'X-status: howdy2';
|
||||
return 404;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
! X-status
|
||||
--- response_body_like: 404 Not Found
|
||||
--- error_code: 404
|
||||
|
||||
|
||||
|
||||
=== TEST 25: -s mixed with -t
|
||||
--- config
|
||||
location /bad {
|
||||
default_type 'text/html';
|
||||
more_set_headers -s 404 -s 200 -t 'text/html' 'X-status: howdy2';
|
||||
echo hi;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
X-status: howdy2
|
||||
--- response_body
|
||||
hi
|
||||
--- error_code: 200
|
||||
|
||||
|
||||
|
||||
=== TEST 26: -s mixed with -t
|
||||
--- config
|
||||
location /bad {
|
||||
default_type 'text/html';
|
||||
more_set_headers -s 500 -s 200 -t 'text/html' 'X-status: howdy2';
|
||||
return 404;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
! X-status
|
||||
--- response_body_like: 404 Not Found
|
||||
--- error_code: 404
|
||||
|
||||
|
||||
|
||||
=== TEST 27: merge from the upper level
|
||||
--- config
|
||||
more_set_headers -s 404 -t 'text/html' 'X-status2: howdy3';
|
||||
location /bad {
|
||||
default_type 'text/html';
|
||||
more_set_headers -s 500 -s 200 -t 'text/html' 'X-status: howdy2';
|
||||
return 404;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
X-status2: howdy3
|
||||
! X-status
|
||||
--- response_body_like: 404 Not Found
|
||||
--- error_code: 404
|
||||
|
||||
|
||||
|
||||
=== TEST 28: merge from the upper level
|
||||
--- config
|
||||
more_set_headers -s 404 -t 'text/html' 'X-status2: howdy3';
|
||||
location /bad {
|
||||
default_type 'text/html';
|
||||
more_set_headers -s 500 -s 200 -t 'text/html' 'X-status: howdy2';
|
||||
echo yeah;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
! X-status2
|
||||
X-status: howdy2
|
||||
--- response_body
|
||||
yeah
|
||||
--- error_code: 200
|
||||
|
||||
|
||||
|
||||
=== TEST 29: override settings by inheritance
|
||||
--- config
|
||||
more_set_headers -s 404 -t 'text/html' 'X-status: yeah';
|
||||
location /bad {
|
||||
default_type 'text/html';
|
||||
more_set_headers -s 404 -t 'text/html' 'X-status: nope';
|
||||
return 404;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
X-status: nope
|
||||
--- response_body_like: 404 Not Found
|
||||
--- error_code: 404
|
||||
|
||||
|
||||
|
||||
=== TEST 30: append settings by inheritance
|
||||
--- config
|
||||
more_set_headers -s 404 -t 'text/html' 'X-status: yeah';
|
||||
location /bad {
|
||||
default_type 'text/html';
|
||||
more_set_headers -s 404 -t 'text/html' 'X-status2: nope';
|
||||
return 404;
|
||||
}
|
||||
--- request
|
||||
GET /bad
|
||||
--- response_headers
|
||||
X-status: yeah
|
||||
X-status2: nope
|
||||
--- response_body_like: 404 Not Found
|
||||
--- error_code: 404
|
||||
|
||||
|
||||
|
||||
=== TEST 31: clear headers with wildcard
|
||||
--- config
|
||||
location = /backend {
|
||||
add_header X-Hidden-One "i am hidden";
|
||||
add_header X-Hidden-Two "me 2";
|
||||
echo hi;
|
||||
}
|
||||
location /hello {
|
||||
more_clear_headers 'X-Hidden-*';
|
||||
proxy_pass http://127.0.0.1:$server_port/backend;
|
||||
}
|
||||
--- request
|
||||
GET /hello
|
||||
--- response_headers
|
||||
! X-Hidden-One
|
||||
! X-Hidden-Two
|
||||
--- response_body
|
||||
hi
|
||||
|
||||
|
||||
|
||||
=== TEST 32: clear duplicate headers
|
||||
--- config
|
||||
location = /backend {
|
||||
add_header pragma no-cache;
|
||||
add_header pragma no-cache;
|
||||
echo hi;
|
||||
}
|
||||
location /hello {
|
||||
more_clear_headers 'pragma';
|
||||
proxy_pass http://127.0.0.1:$server_port/backend;
|
||||
}
|
||||
--- request
|
||||
GET /hello
|
||||
--- response_headers
|
||||
!pragma
|
||||
--- response_body
|
||||
hi
|
||||
|
||||
|
||||
|
||||
=== TEST 33: HTTP 0.9 (set)
|
||||
--- config
|
||||
location /foo {
|
||||
more_set_headers 'X-Foo: howdy';
|
||||
echo ok;
|
||||
}
|
||||
--- raw_request eval
|
||||
"GET /foo\r\n"
|
||||
--- response_headers
|
||||
! X-Foo
|
||||
--- response_body
|
||||
ok
|
||||
--- http09
|
||||
|
||||
69
headers-more-nginx-module-0.32/t/subrequest.t
Normal file
69
headers-more-nginx-module-0.32/t/subrequest.t
Normal file
@@ -0,0 +1,69 @@
|
||||
# vi:filetype=
|
||||
|
||||
use lib 'lib';
|
||||
use Test::Nginx::Socket; # 'no_plan';
|
||||
|
||||
plan tests => blocks() * 3;
|
||||
|
||||
no_diff;
|
||||
|
||||
run_tests();
|
||||
|
||||
__DATA__
|
||||
|
||||
=== TEST 1: vars in input header directives
|
||||
--- config
|
||||
location /main {
|
||||
echo_location /foo;
|
||||
echo "main: $http_user_agent";
|
||||
}
|
||||
location /foo {
|
||||
set $val 'dog';
|
||||
|
||||
more_set_input_headers 'User-Agent: $val';
|
||||
|
||||
proxy_pass http://127.0.0.1:$server_port/proxy;
|
||||
}
|
||||
location /proxy {
|
||||
echo "sub: $http_user_agent";
|
||||
}
|
||||
--- request
|
||||
GET /main
|
||||
--- more_headers
|
||||
User-Agent: my-sock
|
||||
--- response_body
|
||||
sub: dog
|
||||
main: dog
|
||||
--- response_headers
|
||||
! Host
|
||||
--- skip_nginx: 3: < 0.7.46
|
||||
|
||||
|
||||
|
||||
=== TEST 2: vars in input header directives
|
||||
--- config
|
||||
location /main {
|
||||
#more_set_input_headers 'User-Agent: cat';
|
||||
echo_location /foo;
|
||||
echo "main: $http_user_agent";
|
||||
}
|
||||
location /foo {
|
||||
set $val 'dog';
|
||||
|
||||
more_set_input_headers 'User-Agent: $val';
|
||||
|
||||
proxy_pass http://127.0.0.1:$server_port/proxy;
|
||||
#echo $http_user_agent;
|
||||
}
|
||||
location /proxy {
|
||||
echo "sub: $http_user_agent";
|
||||
}
|
||||
--- request
|
||||
GET /main
|
||||
--- response_body
|
||||
sub: dog
|
||||
main: dog
|
||||
--- response_headers
|
||||
! Host
|
||||
--- skip_nginx: 3: < 0.7.46
|
||||
|
||||
175
headers-more-nginx-module-0.32/t/unused.t
Normal file
175
headers-more-nginx-module-0.32/t/unused.t
Normal file
@@ -0,0 +1,175 @@
|
||||
# vi:filetype=
|
||||
|
||||
use lib 'lib';
|
||||
use Test::Nginx::Socket;
|
||||
|
||||
repeat_each(2);
|
||||
|
||||
plan tests => repeat_each() * (blocks() * 4 + 2);
|
||||
|
||||
#master_on();
|
||||
#workers(2);
|
||||
log_level("warn");
|
||||
no_diff;
|
||||
|
||||
run_tests();
|
||||
|
||||
__DATA__
|
||||
|
||||
=== TEST 1: used output filter
|
||||
--- config
|
||||
location /foo {
|
||||
echo hi;
|
||||
more_set_headers "Foo: bar";
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_headers
|
||||
Foo: bar
|
||||
--- response_body
|
||||
hi
|
||||
--- error_log
|
||||
headers more header filter
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- log_level: debug
|
||||
|
||||
|
||||
|
||||
=== TEST 2: unused output filter (none)
|
||||
--- config
|
||||
location /foo {
|
||||
echo hi;
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_body
|
||||
hi
|
||||
--- no_error_log
|
||||
headers more header filter
|
||||
[error]
|
||||
--- log_level: debug
|
||||
|
||||
|
||||
|
||||
=== TEST 3: unused output filter (with more_set_input_headers only)
|
||||
--- config
|
||||
location /foo {
|
||||
more_set_input_headers "Foo: bar";
|
||||
echo hi;
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_body
|
||||
hi
|
||||
--- no_error_log
|
||||
headers more header filter
|
||||
[error]
|
||||
--- log_level: debug
|
||||
|
||||
|
||||
|
||||
=== TEST 4: used rewrite handler
|
||||
--- config
|
||||
location /foo {
|
||||
more_set_input_headers "Foo: bar";
|
||||
echo hi;
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_body
|
||||
hi
|
||||
--- error_log
|
||||
headers more rewrite handler
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- log_level: debug
|
||||
|
||||
|
||||
|
||||
=== TEST 5: unused rewrite handler (none)
|
||||
--- config
|
||||
location /foo {
|
||||
#more_set_input_headers "Foo: bar";
|
||||
echo hi;
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_body
|
||||
hi
|
||||
--- no_error_log
|
||||
headers more rewrite handler
|
||||
[error]
|
||||
--- log_level: debug
|
||||
|
||||
|
||||
|
||||
=== TEST 6: unused rewrite handler (with output header filters)
|
||||
--- config
|
||||
location /foo {
|
||||
#more_set_input_headers "Foo: bar";
|
||||
echo hi;
|
||||
more_set_headers "Foo: bar";
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_headers
|
||||
Foo: bar
|
||||
--- response_body
|
||||
hi
|
||||
--- no_error_log
|
||||
headers more rewrite handler
|
||||
[error]
|
||||
--- log_level: debug
|
||||
|
||||
|
||||
|
||||
=== TEST 7: multiple http {} blocks (filter)
|
||||
This test case won't run with nginx 1.9.3+ since duplicate http {} blocks
|
||||
have been prohibited since then.
|
||||
--- SKIP
|
||||
--- config
|
||||
location /foo {
|
||||
echo hi;
|
||||
more_set_headers 'Foo: bar';
|
||||
}
|
||||
--- post_main_config
|
||||
http {
|
||||
}
|
||||
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_body
|
||||
hi
|
||||
--- response_headers
|
||||
Foo: bar
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- error_log
|
||||
headers more header filter
|
||||
--- log_level: debug
|
||||
|
||||
|
||||
|
||||
=== TEST 8: multiple http {} blocks (handler)
|
||||
This test case won't run with nginx 1.9.3+ since duplicate http {} blocks
|
||||
have been prohibited since then.
|
||||
--- SKIP
|
||||
--- config
|
||||
location /foo {
|
||||
more_set_input_headers 'Foo: bar';
|
||||
echo $http_foo;
|
||||
}
|
||||
--- post_main_config
|
||||
http {
|
||||
}
|
||||
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_body
|
||||
bar
|
||||
--- no_error_log
|
||||
headers more header handler
|
||||
[error]
|
||||
--- log_level: debug
|
||||
|
||||
59
headers-more-nginx-module-0.32/t/vars.t
Normal file
59
headers-more-nginx-module-0.32/t/vars.t
Normal file
@@ -0,0 +1,59 @@
|
||||
# vi:ft=
|
||||
|
||||
use lib 'lib';
|
||||
use Test::Nginx::Socket; # 'no_plan';
|
||||
|
||||
plan tests => 9;
|
||||
|
||||
no_diff;
|
||||
|
||||
run_tests();
|
||||
|
||||
__DATA__
|
||||
|
||||
=== TEST 1: vars
|
||||
--- config
|
||||
location /foo {
|
||||
echo hi;
|
||||
set $val 'hello, world';
|
||||
more_set_headers 'X-Foo: $val';
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_headers
|
||||
X-Foo: hello, world
|
||||
--- response_body
|
||||
hi
|
||||
|
||||
|
||||
|
||||
=== TEST 2: vars in both key and val
|
||||
--- config
|
||||
location /foo {
|
||||
echo hi;
|
||||
set $val 'hello, world';
|
||||
more_set_headers '$val: $val';
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_headers
|
||||
$val: hello, world
|
||||
--- response_body
|
||||
hi
|
||||
|
||||
|
||||
|
||||
=== TEST 3: vars in input header directives
|
||||
--- config
|
||||
location /foo {
|
||||
set $val 'dog';
|
||||
more_set_input_headers 'Host: $val';
|
||||
echo $host;
|
||||
}
|
||||
--- request
|
||||
GET /foo
|
||||
--- response_body
|
||||
dog
|
||||
--- response_headers
|
||||
Host:
|
||||
|
||||
Reference in New Issue
Block a user