… | |
… | |
336 | |
336 | |
337 | Example: do a HTTP HEAD request on https://www.google.com/, use a |
337 | Example: do a HTTP HEAD request on https://www.google.com/, use a |
338 | timeout of 30 seconds. |
338 | timeout of 30 seconds. |
339 | |
339 | |
340 | http_request |
340 | http_request |
341 | GET => "https://www.google.com", |
341 | HEAD => "https://www.google.com", |
342 | headers => { "user-agent" => "MySearchClient 1.0" }, |
342 | headers => { "user-agent" => "MySearchClient 1.0" }, |
343 | timeout => 30, |
343 | timeout => 30, |
344 | sub { |
344 | sub { |
345 | my ($body, $hdr) = @_; |
345 | my ($body, $hdr) = @_; |
346 | use Data::Dumper; |
346 | use Data::Dumper; |
… | |
… | |
428 | |
428 | |
429 | $AnyEvent::HTTP::MAX_RECURSE |
429 | $AnyEvent::HTTP::MAX_RECURSE |
430 | The default value for the "recurse" request parameter (default: 10). |
430 | The default value for the "recurse" request parameter (default: 10). |
431 | |
431 | |
432 | $AnyEvent::HTTP::TIMEOUT |
432 | $AnyEvent::HTTP::TIMEOUT |
433 | The default timeout for conenction operations (default: 300). |
433 | The default timeout for connection operations (default: 300). |
434 | |
434 | |
435 | $AnyEvent::HTTP::USERAGENT |
435 | $AnyEvent::HTTP::USERAGENT |
436 | The default value for the "User-Agent" header (the default is |
436 | The default value for the "User-Agent" header (the default is |
437 | "Mozilla/5.0 (compatible; U; AnyEvent-HTTP/$VERSION; |
437 | "Mozilla/5.0 (compatible; U; AnyEvent-HTTP/$VERSION; |
438 | +http://software.schmorp.de/pkg/AnyEvent)"). |
438 | +http://software.schmorp.de/pkg/AnyEvent)"). |
… | |
… | |
492 | |
492 | |
493 | warn stat $fh; |
493 | warn stat $fh; |
494 | warn -s _; |
494 | warn -s _; |
495 | if (stat $fh and -s _) { |
495 | if (stat $fh and -s _) { |
496 | $ofs = -s _; |
496 | $ofs = -s _; |
497 | warn "-s is ", $ofs;#d# |
497 | warn "-s is ", $ofs; |
498 | $hdr{"if-unmodified-since"} = AnyEvent::HTTP::format_date +(stat _)[9]; |
498 | $hdr{"if-unmodified-since"} = AnyEvent::HTTP::format_date +(stat _)[9]; |
499 | $hdr{"range"} = "bytes=$ofs-"; |
499 | $hdr{"range"} = "bytes=$ofs-"; |
500 | } |
500 | } |
501 | |
501 | |
502 | http_get $url, |
502 | http_get $url, |