… | |
… | |
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; |
… | |
… | |
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, |