MOON
Server: Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4
System: Linux vps.panamaemb.org.sg 3.10.0-1160.80.1.vz7.191.4 #1 SMP Thu Dec 15 20:31:06 MSK 2022 x86_64
User: panama (500)
PHP: 5.2.17
Disabled: NONE
Upload Files
File: //installd/perl588installer/libwww-perl-5.823/t/base/ua.t
#!perl -w

use strict;
use Test;

plan tests => 12;

use LWP::UserAgent;

my $ua = LWP::UserAgent->new;
my $clone = $ua->clone;

ok($ua->agent =~ /^libwww-perl/);
ok(!defined $ua->proxy(ftp => "http://www.sol.no"));
ok($ua->proxy("ftp"), "http://www.sol.no");

my @a = $ua->proxy([qw(ftp http wais)], "http://proxy.foo.com");
for (@a) { $_ = "undef" unless defined; }

ok("@a", "http://www.sol.no undef undef");
ok($ua->proxy("http"), "http://proxy.foo.com");
ok(ref($ua->default_headers), "HTTP::Headers");

$ua->default_header("Foo" => "bar", "Multi" => [1, 2]);
ok($ua->default_headers->header("Foo"), "bar");
ok($ua->default_header("Foo"), "bar");

# Try it
$ua->proxy(http => "loopback:");
$ua->agent("foo/0.1");

ok($ua->get("http://www.example.com", x => "y")->content, <<EOT);
GET http://www.example.com
User-Agent: foo/0.1
Foo: bar
Multi: 1
Multi: 2
X: y

EOT

ok(ref($clone->{proxy}), 'HASH');

ok($ua->proxy(http => undef), "loopback:");
ok($ua->proxy('http'), undef);