File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,13 +19,20 @@ my $CRLF = "\015\012"; # "\r\n" is not portable
1919
2020sub GET { _simple_req(' GET' , @_ ); }
2121sub HEAD { _simple_req(' HEAD' , @_ ); }
22- sub PUT { _simple_req(' PUT' , @_ ); }
2322sub DELETE { _simple_req(' DELETE' , @_ ); }
2423
25- sub POST
24+ for my $type (qw( PUT POST) ) {
25+ no strict ' refs' ;
26+ *{ __PACKAGE__ . " ::" . $type } = sub {
27+ return request_type_with_data($type , @_ );
28+ };
29+ }
30+
31+ sub request_type_with_data
2632{
27- my $url = shift ;
28- my $req = HTTP::Request-> new(POST => $url );
33+ my $type = shift ;
34+ my $url = shift ;
35+ my $req = HTTP::Request-> new($type => $url );
2936 my $content ;
3037 $content = shift if @_ and ref $_ [0];
3138 my ($k , $v );
Original file line number Diff line number Diff line change 11# perl -w
22
33use Test;
4- plan tests => 57 ;
4+ plan tests => 58 ;
55
66use HTTP::Request::Common;
77
@@ -35,6 +35,10 @@ ok(${$r->content_ref}, "foo");
3535ok($r -> content, " foo" );
3636ok($r -> content_length, 3);
3737
38+ $r = PUT " http://www.sn.no" ,
39+ { foo => " bar" };
40+ ok($r -> content, " foo=bar" );
41+
3842# --- Test POST requests ---
3943
4044$r = POST " http://www.sn.no" , [foo => ' bar;baz' ,
@@ -226,4 +230,4 @@ $r = HTTP::Request::Common::PUT 'http://www.example.com',
226230 ' Content-Type' => ' application/octet-steam' ,
227231 ' Content' => ' foobarbaz' ,
228232 ' Content-Length' => 12; # a slight lie
229- ok($r -> header(' Content-Length' ), 12 );
233+ ok($r -> header(' Content-Length' ), 9 );
Original file line number Diff line number Diff line change 33use strict;
44use Test qw( plan ok) ;
55
6- plan tests => 166 ;
6+ plan tests => 175 ;
77
88my ($h , $h2 );
99sub j { join (" |" , @_ ) }
You can’t perform that action at this time.
0 commit comments