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.42 by root, Mon Jul 6 00:08:16 2009 UTC vs.
Revision 1.43 by root, Mon Jul 6 03:03:12 2009 UTC

59our $MAX_PERSISTENT = 8; 59our $MAX_PERSISTENT = 8;
60our $PERSISTENT_TIMEOUT = 2; 60our $PERSISTENT_TIMEOUT = 2;
61our $TIMEOUT = 300; 61our $TIMEOUT = 300;
62 62
63# changing these is evil 63# changing these is evil
64our $MAX_PERSISTENT_PER_HOST = 2; 64our $MAX_PERSISTENT_PER_HOST = 0;
65our $MAX_PER_HOST = 4; 65our $MAX_PER_HOST = 4;
66 66
67our $PROXY; 67our $PROXY;
68our $ACTIVE = 0; 68our $ACTIVE = 0;
69 69
354 $uauthority =~ /^(?: .*\@ )? ([^\@:]+) (?: : (\d+) )?$/x 354 $uauthority =~ /^(?: .*\@ )? ([^\@:]+) (?: : (\d+) )?$/x
355 or return $cb->(undef, { Status => 599, Reason => "Unparsable URL", URL => $url }); 355 or return $cb->(undef, { Status => 599, Reason => "Unparsable URL", URL => $url });
356 356
357 my $uhost = $1; 357 my $uhost = $1;
358 $uport = $2 if defined $2; 358 $uport = $2 if defined $2;
359
360 $hdr{host} = defined $2 ? "$uhost:$2" : "$uhost";
359 361
360 $uhost =~ s/^\[(.*)\]$/$1/; 362 $uhost =~ s/^\[(.*)\]$/$1/;
361 $upath .= "?$query" if length $query; 363 $upath .= "?$query" if length $query;
362 364
363 $upath =~ s%^/?%/%; 365 $upath =~ s%^/?%/%;
406 } 408 }
407 409
408 $hdr{"user-agent"} ||= $USERAGENT; 410 $hdr{"user-agent"} ||= $USERAGENT;
409 $hdr{referer} ||= "$uscheme://$uauthority$upath"; # leave out fragment and query string, just a heuristic 411 $hdr{referer} ||= "$uscheme://$uauthority$upath"; # leave out fragment and query string, just a heuristic
410 412
411 $hdr{host} = "$uhost:$uport";
412 $hdr{"content-length"} = length $arg{body}; 413 $hdr{"content-length"} = length $arg{body};
413 414
414 my %state = (connect_guard => 1); 415 my %state = (connect_guard => 1);
415 416
416 _get_slot $uhost, sub { 417 _get_slot $uhost, sub {
490 # things seen, not parsed: 491 # things seen, not parsed:
491 # p3pP="NON CUR OTPi OUR NOR UNI" 492 # p3pP="NON CUR OTPi OUR NOR UNI"
492 493
493 $hdr{lc $1} .= ",$2" 494 $hdr{lc $1} .= ",$2"
494 while /\G 495 while /\G
495 ([^:\000-\037]+): 496 ([^:\000-\037]*):
496 [\011\040]* 497 [\011\040]*
497 ((?: [^\012]+ | \012[\011\040] )*) 498 ((?: [^\012]+ | \012[\011\040] )*)
498 \012 499 \012
499 /gxc; 500 /gxc;
500 501
654 $finish->((substr delete $_[0]{rbuf}, 0, $len, ""), \%hdr) 655 $finish->((substr delete $_[0]{rbuf}, 0, $len, ""), \%hdr)
655 if $len <= length $_[0]{rbuf}; 656 if $len <= length $_[0]{rbuf};
656 }); 657 });
657 } else { 658 } else {
658 $_[0]->on_error (sub { 659 $_[0]->on_error (sub {
659 $! == Errno::EPIPE 660 $! == Errno::EPIPE || !$!
660 ? $finish->(delete $_[0]{rbuf}, \%hdr) 661 ? $finish->(delete $_[0]{rbuf}, \%hdr)
661 : $finish->(undef, { Status => 599, Reason => $_[2], URL => $url }); 662 : $finish->(undef, { Status => 599, Reason => $_[2], URL => $url });
662 }); 663 });
663 $_[0]->on_read (sub { }); 664 $_[0]->on_read (sub { });
664 } 665 }
732=item $AnyEvent::HTTP::USERAGENT 733=item $AnyEvent::HTTP::USERAGENT
733 734
734The default value for the C<User-Agent> header (the default is 735The default value for the C<User-Agent> header (the default is
735C<Mozilla/5.0 (compatible; U; AnyEvent-HTTP/$VERSION; +http://software.schmorp.de/pkg/AnyEvent)>). 736C<Mozilla/5.0 (compatible; U; AnyEvent-HTTP/$VERSION; +http://software.schmorp.de/pkg/AnyEvent)>).
736 737
737=item $AnyEvent::HTTP::MAX_PERSISTENT 738=item $AnyEvent::HTTP::MAX_PER_HOST
738 739
739The maximum number of persistent connections to keep open (default: 8). 740The maximum number of concurrent conenctions to the same host (identified
741by the hostname). If the limit is exceeded, then the additional requests
742are queued until previous connections are closed.
740 743
741Not implemented currently. 744The default value for this is C<4>, and it is highly advisable to not
742 745increase it.
743=item $AnyEvent::HTTP::PERSISTENT_TIMEOUT
744
745The maximum time to cache a persistent connection, in seconds (default: 2).
746
747Not implemented currently.
748 746
749=item $AnyEvent::HTTP::ACTIVE 747=item $AnyEvent::HTTP::ACTIVE
750 748
751The number of active connections. This is not the number of currently 749The number of active connections. This is not the number of currently
752running requests, but the number of currently open and non-idle TCP 750running requests, but the number of currently open and non-idle TCP

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines