5 # This test tries to make a custom protocol implementation by
6 # subclassing of LWP::Protocol.
12 LWP::Protocol::implementor(http => 'myhttp');
14 $ua = LWP::UserAgent->new;
15 $ua->proxy('ftp' => "http://www.sn.no/");
17 $req = HTTP::Request->new(GET => 'ftp://foo/');
18 $req->header(Cookie => "perl=cool");
20 $res = $ua->request($req);
22 print $res->as_string;
24 print "not " unless $res->code == 200;
26 print "not " unless $res->content eq "Howdy\n";
31 #----------------------------------
35 @ISA=qw(LWP::Protocol);
41 print "CTOR: $class->new(@_)\n";
43 print "not " unless $prot eq "http";
45 my $self = $class->SUPER::new(@_);
48 $v = "<undef>" unless defined($v);
57 print "REQUEST: $self->request(",
58 join(",", (map defined($_)? $_ : "UNDEF", @_)), ")\n";
60 my($request, $proxy, $arg, $size, $timeout) = @_;
61 print $request->as_string;
63 print "not " unless $proxy eq "http://www.sn.no/";
65 print "not " unless $request->url eq "ftp://foo/";
67 print "not " unless $request->header("cookie") eq "perl=cool";
70 my $res = HTTP::Response->new(200 => "OK");
71 $res->content_type("text/plain");
73 $self->collect_once($arg, $res, "Howdy\n");