Debian lenny version packages
[pkg-perl] / deb-src / libwww-perl / libwww-perl-5.813 / t / net / mirror.t
1 #
2 # Test mirroring a file
3 #
4
5 require "net/config.pl";
6 require LWP::Protocol::http;
7 require LWP::UserAgent;
8 require HTTP::Status;
9
10 print "1..2\n";
11
12 my $ua = new LWP::UserAgent;    # create a useragent to test
13
14 my $url = "http://$net::httpserver/";
15 my $copy = "lwp-test-$$"; # downloaded copy
16
17 my $response = $ua->mirror($url, $copy);
18
19 if ($response->code == &HTTP::Status::RC_OK) {
20     print "ok 1\n";
21 }
22 else {
23     print "not ok 1\n";
24 }
25
26 # OK, so now do it again, should get Not-Modified
27 $response = $ua->mirror($url, $copy);
28 if ($response->code == &HTTP::Status::RC_NOT_MODIFIED) {
29     print "ok 2\n";
30 }
31 else {
32     print "nok ok 2\n";
33 }
34 unlink($copy);
35
36 $net::httpserver = $net::httpserver;  # avoid -w warning