~ubuntu-branches/ubuntu/edgy/libwww-perl/edgy

« back to all changes in this revision

Viewing changes to t/base/common-req.t

  • Committer: Bazaar Package Importer
  • Author(s): Jay Bonci
  • Date: 2005-02-13 18:45:32 UTC
  • mfrom: (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050213184532-67qvopi4wre3010u
Tags: 5.803-4
* Make GET/POST/HEAD symlinks (Closes: #294597)
* lwp-requests now honors -b when dumping links (Closes: #294595)
  - Thanks to giuseppe bonacci for the patch
* Moved symlinks to a libwww-perl.links file

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
print "1..19\n";
 
1
print "1..22\n";
2
2
 
3
3
use HTTP::Request::Common;
4
4
 
21
21
 
22
22
$r = PUT "http://www.sn.no",
23
23
     Content => 'foo';
24
 
print $r->as_string;
 
24
print $r->as_string, "\n";
25
25
 
26
26
print "not " unless $r->method eq "PUT" and $r->uri->host eq "www.sn.no";
27
27
print "ok 4\n";
41
41
                               "space " => " + ",
42
42
                              ],
43
43
                              bar => 'foo';
44
 
print $r->as_string;
 
44
print $r->as_string, "\n";
45
45
 
46
46
print "not " unless $r->method eq "POST" and
47
47
                    $r->content_type eq "application/x-www-form-urlencoded" and
117
117
    print "not " unless $r->content =~ /^--\S+\015\012Content-Disposition:\s*form-data;\s*name="file";\s*filename="xxx"/m and
118
118
                        $r->content =~ /^\012Content-Type: text\/html/m and
119
119
                        $r->content =~ /^\012<h1>Hello, world/m;
120
 
} else {
 
120
}
 
121
else {
121
122
    print "not " unless $r->content =~ /^--\S+\015\012Content-Disposition:\s*form-data;\s*name="file";\s*filename="xxx"/m and
122
123
                        $r->content =~ /^Content-Type: text\/html/m and
123
124
                        $r->content =~ /^<h1>Hello, world/m;
137
138
# The POST routine can now also take a hash reference.
138
139
my %hash = (foo => 42, bar => 24);
139
140
$r = POST 'http://www.perl.org/survey.cgi', \%hash;
140
 
print $r->as_string;
 
141
print $r->as_string, "\n";
141
142
print "not " unless $r->content =~ /foo=42/ &&
142
143
                    $r->content =~ /bar=24/ &&
143
144
                    $r->content_type eq "application/x-www-form-urlencoded" &&
166
167
                         born   => '1964',
167
168
                         file   => [$file],
168
169
                       ];
169
 
print $r->as_string;
 
170
print $r->as_string, "\n";
170
171
 
171
172
print "not " unless $r->method eq "POST" and
172
173
                    $r->url->path eq "/survey.cgi" and
197
198
                    abs(length($_) - 26589) < 20;
198
199
print "ok 19\n";
199
200
 
 
201
$r = POST 'http://www.example.com';
 
202
print "not " unless $r->as_string eq <<EOT; print "ok 20\n";
 
203
POST http://www.example.com
 
204
Content-Length: 0
 
205
Content-Type: application/x-www-form-urlencoded
 
206
 
 
207
EOT
 
208
 
 
209
$r = POST 'http://www.example.com', Content_Type => 'form-data', Content => [];
 
210
print "not " unless $r->as_string eq <<EOT; print "ok 21\n";
 
211
POST http://www.example.com
 
212
Content-Length: 0
 
213
Content-Type: multipart/form-data; boundary=none
 
214
 
 
215
EOT
 
216
 
 
217
$r = POST 'http://www.example.com', Content_Type => 'form-data';
 
218
#print $r->as_string;
 
219
print "not " unless $r->as_string eq <<EOT; print "ok 22\n";
 
220
POST http://www.example.com
 
221
Content-Length: 0
 
222
Content-Type: multipart/form-data
 
223
 
 
224
EOT
 
225