ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-HTTP/HTTP.pm
(Generate patch)

Comparing AnyEvent-HTTP/HTTP.pm (file contents):
Revision 1.35 by root, Thu Oct 30 03:47:01 2008 UTC vs.
Revision 1.38 by root, Sat Mar 7 03:43:09 2009 UTC

48use AnyEvent::Socket (); 48use AnyEvent::Socket ();
49use AnyEvent::Handle (); 49use AnyEvent::Handle ();
50 50
51use base Exporter::; 51use base Exporter::;
52 52
53our $VERSION = '1.1'; 53our $VERSION = '1.11';
54 54
55our @EXPORT = qw(http_get http_post http_head http_request); 55our @EXPORT = qw(http_get http_post http_head http_request);
56 56
57our $USERAGENT = "Mozilla/5.0 (compatible; AnyEvent::HTTP/$VERSION; +http://software.schmorp.de/pkg/AnyEvent)"; 57our $USERAGENT = "Mozilla/5.0 (compatible; AnyEvent::HTTP/$VERSION; +http://software.schmorp.de/pkg/AnyEvent)";
58our $MAX_RECURSE = 10; 58our $MAX_RECURSE = 10;
320 } 320 }
321 321
322 my ($rhost, $rport, $rscheme, $rpath); # request host, port, path 322 my ($rhost, $rport, $rscheme, $rpath); # request host, port, path
323 323
324 if ($proxy) { 324 if ($proxy) {
325 ($rhost, $rport, $rscheme, $rpath) = (@$proxy, $url); 325 ($rpath, $rhost, $rport, $rscheme) = ($url, @$proxy);
326 326
327 # don't support https requests over https-proxy transport, 327 # don't support https requests over https-proxy transport,
328 # can't be done with tls as spec'ed. 328 # can't be done with tls as spec'ed, unless you double-encrypt.
329 $rscheme = "http" if $uscheme eq "https" && $rscheme eq "https"; 329 $rscheme = "http" if $uscheme eq "https" && $rscheme eq "https";
330 } else { 330 } else {
331 ($rhost, $rport, $rscheme, $rpath) = ($uhost, $uport, $uscheme, $upath); 331 ($rhost, $rport, $rscheme, $rpath) = ($uhost, $uport, $uscheme, $upath);
332 } 332 }
333 333
525 }); 525 });
526 } else { 526 } else {
527 # too bad, need to read until we get an error or EOF, 527 # too bad, need to read until we get an error or EOF,
528 # no way to detect winged data. 528 # no way to detect winged data.
529 $_[0]->on_error (sub { 529 $_[0]->on_error (sub {
530 # delete ought to be more efficient, as we would have to make
531 # a copy otherwise as $_[0] gets destroyed.
530 $finish->($_[0]{rbuf}, \%hdr); 532 $finish->(delete $_[0]{rbuf}, \%hdr);
531 }); 533 });
532 $_[0]->on_eof (undef); 534 $_[0]->on_eof (undef);
533 $_[0]->on_read (sub { }); 535 $_[0]->on_read (sub { });
534 } 536 }
535 } 537 }
639=head1 AUTHOR 641=head1 AUTHOR
640 642
641 Marc Lehmann <schmorp@schmorp.de> 643 Marc Lehmann <schmorp@schmorp.de>
642 http://home.schmorp.de/ 644 http://home.schmorp.de/
643 645
646With many thanks to Дмитрий Шалашов, who provided countless
647testcases and bugreports.
648
644=cut 649=cut
645 650
6461 6511
647 652

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines