comparison http_uri.t @ 1635:7b80c8e0479a

Tests: absolute URI parsing tests.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 10 Dec 2020 23:54:32 +0300
parents eb33558f731d
children 5ac6efbe5552
comparison
equal deleted inserted replaced
1634:12f32d82936d 1635:7b80c8e0479a
20 ############################################################################### 20 ###############################################################################
21 21
22 select STDERR; $| = 1; 22 select STDERR; $| = 1;
23 select STDOUT; $| = 1; 23 select STDOUT; $| = 1;
24 24
25 my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(8) 25 my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(17)
26 ->write_file_expand('nginx.conf', <<'EOF')->run(); 26 ->write_file_expand('nginx.conf', <<'EOF')->run();
27 27
28 %%TEST_GLOBALS%% 28 %%TEST_GLOBALS%%
29 29
30 daemon off; 30 daemon off;
38 server { 38 server {
39 listen 127.0.0.1:8080; 39 listen 127.0.0.1:8080;
40 server_name localhost; 40 server_name localhost;
41 41
42 location / { 42 location / {
43 add_header X-URI "x $uri x"; 43 add_header X-URI "x $uri x";
44 add_header X-Args "y $args y";
45 add_header X-Request-URI "z $request_uri z";
44 return 204; 46 return 204;
45 } 47 }
46 } 48 }
47 } 49 }
48 50
49 EOF 51 EOF
50 52
51 ############################################################################### 53 ###############################################################################
52
53 local $TODO = 'not yet' unless $t->has_version('1.17.5');
54 54
55 like(http_get('/foo/bar%'), qr/400 Bad/, 'percent'); 55 like(http_get('/foo/bar%'), qr/400 Bad/, 'percent');
56 like(http_get('/foo/bar%1'), qr/400 Bad/, 'percent digit'); 56 like(http_get('/foo/bar%1'), qr/400 Bad/, 'percent digit');
57 57
58 like(http_get('/foo/bar/.?args'), qr!x /foo/bar/ x!, 'dot args'); 58 like(http_get('/foo/bar/.?args'), qr!x /foo/bar/ x!, 'dot args');
60 like(http_get('/foo/bar/..?args'), qr!x /foo/ x!, 'dot dot args'); 60 like(http_get('/foo/bar/..?args'), qr!x /foo/ x!, 'dot dot args');
61 like(http_get('/foo/bar/..#frag'), qr!x /foo/ x!, 'dot dot frag'); 61 like(http_get('/foo/bar/..#frag'), qr!x /foo/ x!, 'dot dot frag');
62 like(http_get('/foo/bar/.'), qr!x /foo/bar/ x!, 'trailing dot'); 62 like(http_get('/foo/bar/.'), qr!x /foo/bar/ x!, 'trailing dot');
63 like(http_get('/foo/bar/..'), qr!x /foo/ x!, 'trailing dot dot'); 63 like(http_get('/foo/bar/..'), qr!x /foo/ x!, 'trailing dot dot');
64 64
65 like(http_get('http://localhost'), qr!x / x!, 'absolute');
66 like(http_get('http://localhost/'), qr!x / x!, 'absolute slash');
67
68 TODO: {
69 local $TODO = 'not yet' unless $t->has_version('1.19.6');
70
71 like(http_get('http://localhost?args'), qr!x / x.*y args y!ms,
72 'absolute args');
73 like(http_get('http://localhost?args#frag'), qr!x / x.*y args y!ms,
74 'absolute args and frag');
75
76 }
77
78 like(http_get('http://localhost:8080'), qr!x / x!, 'port');
79 like(http_get('http://localhost:8080/'), qr!x / x!, 'port slash');
80
81 TODO: {
82 local $TODO = 'not yet' unless $t->has_version('1.19.6');
83
84 like(http_get('http://localhost:8080?args'), qr!x / x.*y args y!ms,
85 'port args');
86 like(http_get('http://localhost:8080?args#frag'), qr!x / x.*y args y!ms,
87 'port args and frag');
88
89 }
90
91 like(http_get('/ /'), qr!x / / x!, 'space');
92
65 ############################################################################### 93 ###############################################################################