File: socks4.t

package info (click to toggle)
liblwp-protocol-socks-perl 1.7-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 92 kB
  • sloc: perl: 140; makefile: 2
file content (29 lines) | stat: -r--r--r-- 928 bytes parent folder | download | duplicates (4)
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
# -*- mode: perl -*-
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl LWP-Protocol-socks.t'

#########################

use Test::More;

if ($ENV{SOCKS_PROXY}) {
    plan tests => 3;
}
else {
    plan skip_all => 'no proxy defined; set SOCKS_PROXY';
}

use_ok(qw(LWP::UserAgent));
#########################

# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.

my $ua = new LWP::UserAgent(agent => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.5) Gecko/20060719 Firefox/1.5.0.5');
ok($ua, 'got ua');

$ua->proxy([qw(http https)] => "socks4://$ENV{SOCKS_PROXY}");

my $response = $ua->get("http://www.freebsd.org");
is($response->code, 200, 'get www.freebsd.org code is 200')
    or diag(join(' ',$response->code,$response->message));