… | |
… | |
54 | The callback will be called with the response body data as first |
54 | The callback will be called with the response body data as first |
55 | argument (or "undef" if an error occured), and a hash-ref with |
55 | argument (or "undef" if an error occured), and a hash-ref with |
56 | response headers as second argument. |
56 | response headers as second argument. |
57 | |
57 | |
58 | All the headers in that hash are lowercased. In addition to the |
58 | All the headers in that hash are lowercased. In addition to the |
59 | response headers, the "pseudo-headers" "HTTPVersion", "Status" and |
59 | response headers, the "pseudo-headers" (uppercase to avoid clashing |
|
|
60 | with possible response headers) "HTTPVersion", "Status" and "Reason" |
60 | "Reason" contain the three parts of the HTTP Status-Line of the same |
61 | contain the three parts of the HTTP Status-Line of the same name. |
|
|
62 | |
61 | name. The pseudo-header "URL" contains the original URL (which can |
63 | The pseudo-header "URL" contains the actual URL (which can differ |
62 | differ from the requested URL when following redirects). |
64 | from the requested URL when following redirects - for example, you |
|
|
65 | might get an error that your URL scheme is not supported even though |
|
|
66 | your URL is a valid http URL because it redirected to an ftp URL, in |
|
|
67 | which case you can look at the URL pseudo header). |
|
|
68 | |
|
|
69 | The pseudo-header "Redirect" only exists when the request was a |
|
|
70 | result of an internal redirect. In that case it is an array |
|
|
71 | reference with the "($data, $headers)" from the redirect response. |
|
|
72 | Note that this response could in turn be the result of a redirect |
|
|
73 | itself, and "$headers->{Redirect}[1]{Redirect}" will then contain |
|
|
74 | the original response, and so on. |
63 | |
75 | |
64 | If the server sends a header multiple times, then their contents |
76 | If the server sends a header multiple times, then their contents |
65 | will be joined together with a comma (","), as per the HTTP spec. |
77 | will be joined together with a comma (","), as per the HTTP spec. |
66 | |
78 | |
67 | If an internal error occurs, such as not being able to resolve a |
79 | If an internal error occurs, such as not being able to resolve a |
… | |
… | |
244 | print "$body\n"; |
256 | print "$body\n"; |
245 | }; |
257 | }; |
246 | |
258 | |
247 | undef $request; |
259 | undef $request; |
248 | |
260 | |
|
|
261 | DNS CACHING |
|
|
262 | AnyEvent::HTTP uses the AnyEvent::Socket::tcp_connect function for the |
|
|
263 | actual connection, which in turn uses AnyEvent::DNS to resolve |
|
|
264 | hostnames. The latter is a simple stub resolver and does no caching on |
|
|
265 | its own. If you want DNS caching, you currently have to provide your own |
|
|
266 | default resolver (by storing a suitable resolver object in |
|
|
267 | $AnyEvent::DNS::RESOLVER). |
|
|
268 | |
249 | GLOBAL FUNCTIONS AND VARIABLES |
269 | GLOBAL FUNCTIONS AND VARIABLES |
250 | AnyEvent::HTTP::set_proxy "proxy-url" |
270 | AnyEvent::HTTP::set_proxy "proxy-url" |
251 | Sets the default proxy server to use. The proxy-url must begin with |
271 | Sets the default proxy server to use. The proxy-url must begin with |
252 | a string of the form "http://host:port" (optionally "https:..."), |
272 | a string of the form "http://host:port" (optionally "https:..."), |
253 | croaks otherwise. |
273 | croaks otherwise. |