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.72 by root, Fri Dec 31 20:59:19 2010 UTC vs.
Revision 1.75 by root, Sat Jan 1 00:08:51 2011 UTC

412 412
413 \@cookies 413 \@cookies
414} 414}
415 415
416# parse set_cookie header into jar 416# parse set_cookie header into jar
417sub cookie_jar_set_cookie($$) { 417sub cookie_jar_set_cookie($$$) {
418 my ($jar, $set_cookie) = @_; 418 my ($jar, $set_cookie, $uhost) = @_;
419 419
420 for ($set_cookie) { 420 for ($set_cookie) {
421 # parse NAME=VALUE 421 # parse NAME=VALUE
422 my @kv; 422 my @kv;
423 423
472 } else { 472 } else {
473 $cdom = $uhost; 473 $cdom = $uhost;
474 } 474 }
475 475
476 # store it 476 # store it
477 $arg{cookie_jar}{version} = 1; 477 $jar->{version} = 1;
478 $arg{cookie_jar}{$cdom}{$cpath}{$name} = \%kv; 478 $jar->{$cdom}{$cpath}{$name} = \%kv;
479 479
480 redo if /\G\s*,/gc; 480 redo if /\G\s*,/gc;
481 } 481 }
482}
483} 482}
484 483
485# continue to parse $_ for headers and place them into the arg 484# continue to parse $_ for headers and place them into the arg
486sub parse_hdr() { 485sub parse_hdr() {
487 my %hdr; 486 my %hdr;
608 or do { 607 or do {
609 my $err = "$!"; 608 my $err = "$!";
610 %state = (); 609 %state = ();
611 return $cb->(undef, { @pseudo, Status => 599, Reason => $err }); 610 return $cb->(undef, { @pseudo, Status => 599, Reason => $err });
612 }; 611 };
613
614 pop; # free memory, save a tree
615 612
616 return unless delete $state{connect_guard}; 613 return unless delete $state{connect_guard};
617 614
618 # get handle 615 # get handle
619 $state{handle} = new AnyEvent::Handle 616 $state{handle} = new AnyEvent::Handle
723 $redirect = 1; 720 $redirect = 1;
724 } 721 }
725 } 722 }
726 723
727 my $finish = sub { # ($data, $err_status, $err_reason[, $keepalive]) 724 my $finish = sub { # ($data, $err_status, $err_reason[, $keepalive])
728 my $keepalive = pop; 725 my $may_keep_alive = $_[3];
729 726
730 $state{handle}->destroy if $state{handle}; 727 $state{handle}->destroy if $state{handle};
731 %state = (); 728 %state = ();
732 729
733 if (defined $_[1]) { 730 if (defined $_[1]) {
735 $hdr{OrigReason} = $hdr{Reason}; $hdr{Reason} = $_[2]; 732 $hdr{OrigReason} = $hdr{Reason}; $hdr{Reason} = $_[2];
736 } 733 }
737 734
738 # set-cookie processing 735 # set-cookie processing
739 if ($arg{cookie_jar}) { 736 if ($arg{cookie_jar}) {
740 cookie_jar_set_cookie $arg{cookie_jar}, $hdr{"set-cookie"}; 737 cookie_jar_set_cookie $arg{cookie_jar}, $hdr{"set-cookie"}, $uhost;
738 }
741 739
742 if ($redirect && exists $hdr{location}) { 740 if ($redirect && exists $hdr{location}) {
743 # we ignore any errors, as it is very common to receive 741 # we ignore any errors, as it is very common to receive
744 # Content-Length != 0 but no actual body 742 # Content-Length != 0 but no actual body
745 # we also access %hdr, as $_[1] might be an erro 743 # we also access %hdr, as $_[1] might be an erro

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines