Debian lenny version packages
[pkg-perl] / deb-src / liburi-perl / liburi-perl-1.35.dfsg.1 / t / http.t
1 #!perl -w
2
3 print "1..13\n";
4
5 use URI;
6
7 $u = URI->new("<http://www.perl.com/path?q=fôo>");
8
9 #print "$u\n";
10 print "not " unless $u eq "http://www.perl.com/path?q=f%F4o";
11 print "ok 1\n";
12
13 print "not " unless $u->port == 80;
14 print "ok 2\n";
15
16 # play with port
17 $old = $u->port(8080);
18 print "not " unless $old == 80 && $u eq "http://www.perl.com:8080/path?q=f%F4o";
19 print "ok 3\n";
20
21 $u->port(80);
22 print "not " unless $u eq "http://www.perl.com:80/path?q=f%F4o";
23 print "ok 4\n";
24
25 $u->port("");
26 print "not " unless $u eq "http://www.perl.com:/path?q=f%F4o" && $u->port == 80;
27 print "ok 5\n";
28
29 $u->port(undef);
30 print "not " unless $u eq "http://www.perl.com/path?q=f%F4o";
31 print "ok 6\n";
32
33 @q = $u->query_form;
34 print "not " unless @q == 2 && "@q" eq "q fôo";
35 print "ok 7\n";
36
37 $u->query_form(foo => "bar", bar => "baz");
38 print "not " unless $u->query eq "foo=bar&bar=baz";
39 print "ok 8\n";
40
41 print "not " unless $u->host eq "www.perl.com";
42 print "ok 9\n";
43
44 print "not " unless $u->path eq "/path";
45 print "ok 10\n";
46
47 $u->scheme("https");
48 print "not " unless $u->port == 443;
49 print "ok 11\n";
50
51 print "not " unless $u eq "https://www.perl.com/path?foo=bar&bar=baz";
52 print "ok 12\n";
53
54 $u = URI->new("http://%77%77%77%2e%70%65%72%6c%2e%63%6f%6d/%70%75%62/%61/%32%30%30%31/%30%38/%32%37/%62%6a%6f%72%6e%73%74%61%64%2e%68%74%6d%6c");
55 print "not " unless $u->canonical eq "http://www.perl.com/pub/a/2001/08/27/bjornstad.html";
56 print "ok 13\n";
57