summaryrefslogtreecommitdiff
path: root/t/http.t
blob: aef92737e2be9a2eeec6aaa327fc3e98166c917a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use strict;
use warnings;

use Test::More tests => 16;

use URI ();

my $u = URI->new("<http://www.example.com/path?q=fôo>");

#print "$u\n";
is($u, "http://www.example.com/path?q=f%F4o");

is($u->port, 80);

# play with port
my $old = $u->port(8080);
ok($old == 80 && $u eq "http://www.example.com:8080/path?q=f%F4o");

$u->port(80);
is($u, "http://www.example.com:80/path?q=f%F4o");

$u->port("");
ok($u eq "http://www.example.com:/path?q=f%F4o" && $u->port == 80);

$u->port(undef);
is($u, "http://www.example.com/path?q=f%F4o");

my @q = $u->query_form;
is_deeply(\@q, ["q", "fôo"]);

$u->query_form(foo => "bar", bar => "baz");
is($u->query, "foo=bar&bar=baz");

is($u->host, "www.example.com");

is($u->path, "/path");

ok(!$u->secure);

$u->scheme("https");
is($u->port, 443);

is($u, "https://www.example.com/path?foo=bar&bar=baz");

ok($u->secure);

$u = URI->new("http://%65%78%61%6d%70%6c%65%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");
is($u->canonical, "http://example.com/pub/a/2001/08/27/bjornstad.html");

ok($u->has_recognized_scheme);