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

Comparing AnyEvent-HTTP/README (file contents):
Revision 1.4 by root, Thu Jul 24 06:01:10 2008 UTC vs.
Revision 1.5 by root, Thu Oct 23 02:46:20 2008 UTC

28 limited support. 28 limited support.
29 29
30 METHODS 30 METHODS
31 http_get $url, key => value..., $cb->($data, $headers) 31 http_get $url, key => value..., $cb->($data, $headers)
32 Executes an HTTP-GET request. See the http_request function for 32 Executes an HTTP-GET request. See the http_request function for
33 details on additional parameters. 33 details on additional parameters and the return value.
34 34
35 http_head $url, key => value..., $cb->($data, $headers) 35 http_head $url, key => value..., $cb->($data, $headers)
36 Executes an HTTP-HEAD request. See the http_request function for 36 Executes an HTTP-HEAD request. See the http_request function for
37 details on additional parameters. 37 details on additional parameters and the return value.
38 38
39 http_post $url, $body, key => value..., $cb->($data, $headers) 39 http_post $url, $body, key => value..., $cb->($data, $headers)
40 Executes an HTTP-POST request with a request body of $body. See the 40 Executes an HTTP-POST request with a request body of $body. See the
41 http_request function for details on additional parameters. 41 http_request function for details on additional parameters and the
42 return value.
42 43
43 http_request $method => $url, key => value..., $cb->($data, $headers) 44 http_request $method => $url, key => value..., $cb->($data, $headers)
44 Executes a HTTP request of type $method (e.g. "GET", "POST"). The 45 Executes a HTTP request of type $method (e.g. "GET", "POST"). The
45 URL must be an absolute http or https URL. 46 URL must be an absolute http or https URL.
47
48 When called in void context, nothing is returned. In other contexts,
49 "http_request" returns a "cancellation guard" - you have to keep the
50 object at least alive until the callback get called. If the object
51 gets destroyed before the callbakc is called, the request will be
52 cancelled.
46 53
47 The callback will be called with the response data as first argument 54 The callback will be called with the response data as first argument
48 (or "undef" if it wasn't available due to errors), and a hash-ref 55 (or "undef" if it wasn't available due to errors), and a hash-ref
49 with response headers as second argument. 56 with response headers as second argument.
50 57
138 use Data::Dumper; 145 use Data::Dumper;
139 print Dumper $hdr; 146 print Dumper $hdr;
140 } 147 }
141 ; 148 ;
142 149
150 Example: make another simple HTTP GET request, but immediately try
151 to cancel it.
152
153 my $request = http_request GET => "http://www.nethype.de/", sub {
154 my ($body, $hdr) = @_;
155 print "$body\n";
156 };
157
158 undef $request;
159
143 GLOBAL FUNCTIONS AND VARIABLES 160 GLOBAL FUNCTIONS AND VARIABLES
144 AnyEvent::HTTP::set_proxy "proxy-url" 161 AnyEvent::HTTP::set_proxy "proxy-url"
145 Sets the default proxy server to use. The proxy-url must begin with 162 Sets the default proxy server to use. The proxy-url must begin with
146 a string of the form "http://host:port" (optionally "https:..."). 163 a string of the form "http://host:port" (optionally "https:...").
147 164

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines