ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-HTTP/HTTP.pm
(Generate patch)

Comparing AnyEvent-HTTP/HTTP.pm (file contents):
Revision 1.28 by root, Mon Sep 29 13:50:39 2008 UTC vs.
Revision 1.29 by root, Wed Oct 22 23:28:11 2008 UTC

71my %CO_SLOT; # number of open connections, and wait queue, per host 71my %CO_SLOT; # number of open connections, and wait queue, per host
72 72
73=item http_get $url, key => value..., $cb->($data, $headers) 73=item http_get $url, key => value..., $cb->($data, $headers)
74 74
75Executes an HTTP-GET request. See the http_request function for details on 75Executes an HTTP-GET request. See the http_request function for details on
76additional parameters. 76additional parameters and the return value.
77 77
78=item http_head $url, key => value..., $cb->($data, $headers) 78=item http_head $url, key => value..., $cb->($data, $headers)
79 79
80Executes an HTTP-HEAD request. See the http_request function for details on 80Executes an HTTP-HEAD request. See the http_request function for details
81additional parameters. 81on additional parameters and the return value.
82 82
83=item http_post $url, $body, key => value..., $cb->($data, $headers) 83=item http_post $url, $body, key => value..., $cb->($data, $headers)
84 84
85Executes an HTTP-POST request with a request body of C<$body>. See the 85Executes an HTTP-POST request with a request body of C<$body>. See the
86http_request function for details on additional parameters. 86http_request function for details on additional parameters and the return
87value.
87 88
88=item http_request $method => $url, key => value..., $cb->($data, $headers) 89=item http_request $method => $url, key => value..., $cb->($data, $headers)
89 90
90Executes a HTTP request of type C<$method> (e.g. C<GET>, C<POST>). The URL 91Executes a HTTP request of type C<$method> (e.g. C<GET>, C<POST>). The URL
91must be an absolute http or https URL. 92must be an absolute http or https URL.
93
94When called in void context, nothing is returned. In other contexts,
95C<http_request> returns a "cancellation guard" - you have to keep the
96object at least alive until the callback get called. If the object gets
97destroyed before the callbakc is called, the request will be cancelled.
92 98
93The callback will be called with the response data as first argument 99The callback will be called with the response data as first argument
94(or C<undef> if it wasn't available due to errors), and a hash-ref with 100(or C<undef> if it wasn't available due to errors), and a hash-ref with
95response headers as second argument. 101response headers as second argument.
96 102
188 my ($body, $hdr) = @_; 194 my ($body, $hdr) = @_;
189 use Data::Dumper; 195 use Data::Dumper;
190 print Dumper $hdr; 196 print Dumper $hdr;
191 } 197 }
192 ; 198 ;
199
200Example: make another simple HTTP GET request, but immediately try to
201cancel it.
202
203 my $request = http_request GET => "http://www.nethype.de/", sub {
204 my ($body, $hdr) = @_;
205 print "$body\n";
206 };
207
208 undef $request;
193 209
194=cut 210=cut
195 211
196sub _slot_schedule; 212sub _slot_schedule;
197sub _slot_schedule($) { 213sub _slot_schedule($) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines