… | |
… | |
46 | use AnyEvent::Util (); |
46 | use AnyEvent::Util (); |
47 | use AnyEvent::Handle (); |
47 | use AnyEvent::Handle (); |
48 | |
48 | |
49 | use base Exporter::; |
49 | use base Exporter::; |
50 | |
50 | |
51 | our $VERSION = '2.12'; |
51 | our $VERSION = '2.13'; |
52 | |
52 | |
53 | our @EXPORT = qw(http_get http_post http_head http_request); |
53 | our @EXPORT = qw(http_get http_post http_head http_request); |
54 | |
54 | |
55 | our $USERAGENT = "Mozilla/5.0 (compatible; U; AnyEvent-HTTP/$VERSION; +http://software.schmorp.de/pkg/AnyEvent)"; |
55 | our $USERAGENT = "Mozilla/5.0 (compatible; U; AnyEvent-HTTP/$VERSION; +http://software.schmorp.de/pkg/AnyEvent)"; |
56 | our $MAX_RECURSE = 10; |
56 | our $MAX_RECURSE = 10; |
… | |
… | |
384 | |
384 | |
385 | Example: do a HTTP HEAD request on https://www.google.com/, use a |
385 | Example: do a HTTP HEAD request on https://www.google.com/, use a |
386 | timeout of 30 seconds. |
386 | timeout of 30 seconds. |
387 | |
387 | |
388 | http_request |
388 | http_request |
389 | GET => "https://www.google.com", |
389 | HEAD => "https://www.google.com", |
390 | headers => { "user-agent" => "MySearchClient 1.0" }, |
390 | headers => { "user-agent" => "MySearchClient 1.0" }, |
391 | timeout => 30, |
391 | timeout => 30, |
392 | sub { |
392 | sub { |
393 | my ($body, $hdr) = @_; |
393 | my ($body, $hdr) = @_; |
394 | use Data::Dumper; |
394 | use Data::Dumper; |