… | |
… | |
48 | use AnyEvent::Socket (); |
48 | use AnyEvent::Socket (); |
49 | use AnyEvent::Handle (); |
49 | use AnyEvent::Handle (); |
50 | |
50 | |
51 | use base Exporter::; |
51 | use base Exporter::; |
52 | |
52 | |
53 | our $VERSION = '1.4'; |
53 | our $VERSION = '1.41'; |
54 | |
54 | |
55 | our @EXPORT = qw(http_get http_post http_head http_request); |
55 | our @EXPORT = qw(http_get http_post http_head http_request); |
56 | |
56 | |
57 | our $USERAGENT = "Mozilla/5.0 (compatible; U; AnyEvent-HTTP/$VERSION; +http://software.schmorp.de/pkg/AnyEvent)"; |
57 | our $USERAGENT = "Mozilla/5.0 (compatible; U; AnyEvent-HTTP/$VERSION; +http://software.schmorp.de/pkg/AnyEvent)"; |
58 | our $MAX_RECURSE = 10; |
58 | our $MAX_RECURSE = 10; |
… | |
… | |
312 | push @{ $CO_SLOT{$_[0]}[1] }, $_[1]; |
312 | push @{ $CO_SLOT{$_[0]}[1] }, $_[1]; |
313 | |
313 | |
314 | _slot_schedule $_[0]; |
314 | _slot_schedule $_[0]; |
315 | } |
315 | } |
316 | |
316 | |
317 | our $qr_nl = qr<\015?\012>; |
317 | our $qr_nl = qr{\015?\012}; |
318 | our $qr_nlnl = qr<\015?\012\015?\012>; |
318 | our $qr_nlnl = qr{(?<![^\012])\015?\012}; |
319 | |
319 | |
320 | our $TLS_CTX_LOW = { cache => 1, sslv2 => 1 }; |
320 | our $TLS_CTX_LOW = { cache => 1, sslv2 => 1 }; |
321 | our $TLS_CTX_HIGH = { cache => 1, verify => 1, verify_peername => "https" }; |
321 | our $TLS_CTX_HIGH = { cache => 1, verify => 1, verify_peername => "https" }; |
322 | |
322 | |
323 | sub http_request($$@) { |
323 | sub http_request($$@) { |
… | |
… | |
491 | URL => ",$url" |
491 | URL => ",$url" |
492 | ); |
492 | ); |
493 | |
493 | |
494 | # headers, could be optimized a bit |
494 | # headers, could be optimized a bit |
495 | $state{handle}->unshift_read (line => $qr_nlnl, sub { |
495 | $state{handle}->unshift_read (line => $qr_nlnl, sub { |
496 | for ("$_[1]\012") { |
496 | for ("$_[1]") { |
497 | y/\015//d; # weed out any \015, as they show up in the weirdest of places. |
497 | y/\015//d; # weed out any \015, as they show up in the weirdest of places. |
498 | |
498 | |
499 | # things seen, not parsed: |
499 | # things seen, not parsed: |
500 | # p3pP="NON CUR OTPi OUR NOR UNI" |
500 | # p3pP="NON CUR OTPi OUR NOR UNI" |
501 | |
501 | |