Debian lenny version packages
[pkg-perl] / deb-src / libwww-perl / libwww-perl-5.813 / t / net / http-get.t
1 #!/usr/local/bin/perl -w
2 #
3 # Check GET via HTTP.
4 #
5
6 print "1..2\n";
7
8 require "net/config.pl";
9 require LWP::Protocol::http;
10 require LWP::UserAgent;
11
12 my $ua = new LWP::UserAgent;    # create a useragent to test
13
14 $netloc = $net::httpserver;
15 $script = $net::cgidir . "/test";
16
17 $url = new URI::URL("http://$netloc$script?query");
18
19 my $request = new HTTP::Request('GET', $url);
20
21 print "GET $url\n\n";
22
23 my $response = $ua->request($request, undef, undef);
24
25 my $str = $response->as_string;
26
27 print "$str\n";
28
29 if ($response->is_success and $str =~ /^REQUEST_METHOD=GET$/m) {
30     print "ok 1\n";
31 }
32 else {
33     print "not ok 1\n";
34 }
35
36 if ($str =~ /^QUERY_STRING=query$/m) {
37     print "ok 2\n";
38 }
39 else {
40     print "not ok 2\n";
41 }
42
43 # avoid -w warning
44 $dummy = $net::httpserver;
45 $dummy = $net::cgidir;