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.24 by root, Wed Jul 2 01:30:33 2008 UTC vs.
Revision 1.25 by root, Mon Jul 21 05:42:07 2008 UTC

355 355
356 %hdr = (); # reduce memory usage, save a kitten 356 %hdr = (); # reduce memory usage, save a kitten
357 357
358 # status line 358 # status line
359 $state{handle}->push_read (line => qr/\015?\012/, sub { 359 $state{handle}->push_read (line => qr/\015?\012/, sub {
360 $_[1] =~ /^HTTP\/([0-9\.]+) \s+ ([0-9]{3}) \s+ ([^\015\012]+)/ix 360 $_[1] =~ /^HTTP\/([0-9\.]+) \s+ ([0-9]{3}) (?: \s+ ([^\015\012]*) )?/ix
361 or return (%state = (), $cb->(undef, { Status => 599, Reason => "invalid server response ($_[1])", URL => $url })); 361 or return (%state = (), $cb->(undef, { Status => 599, Reason => "invalid server response ($_[1])", URL => $url }));
362 362
363 my %hdr = ( # response headers 363 my %hdr = ( # response headers
364 HTTPVersion => "\x00$1", 364 HTTPVersion => "\x00$1",
365 Status => "\x00$2", 365 Status => "\x00$2",
412 $arg{cookie_jar}{version} = 1; 412 $arg{cookie_jar}{version} = 1;
413 $arg{cookie_jar}{$cdom}{$cpath}{$name} = \%kv; 413 $arg{cookie_jar}{$cdom}{$cpath}{$name} = \%kv;
414 } 414 }
415 } 415 }
416 416
417 # microsoft and other assholes don't give a shit for following standards, 417 # microsoft and other shitheads don't give a shit for following standards,
418 # try to support a common form of broken Location header. 418 # try to support some common forms of broken Location headers.
419 $_[1]{location} =~ s%^/%$scheme://$uhost:$uport/% 419 if ($_[1]{location} !~ /^(?: $ | [^:\/?\#]+ : )/x) {
420 $_[1]{location} =~ s/^\.\/+//;
421
422 my $url = "$scheme://$uhost:$uport";
423
420 if exists $_[1]{location}; 424 unless ($_[1]{location} =~ s/^\///) {
425 $url .= $upath;
426 $url =~ s/\/[^\/]*$//;
427 }
428
429 $_[1]{location} = "$url/$_[1]{location}";
430 }
421 431
422 if ($_[1]{Status} =~ /^30[12]$/ && $recurse && $method ne "POST") { 432 if ($_[1]{Status} =~ /^30[12]$/ && $recurse && $method ne "POST") {
423 # apparently, mozilla et al. just change POST to GET here 433 # apparently, mozilla et al. just change POST to GET here
424 # more research is needed before we do the same 434 # more research is needed before we do the same
425 http_request ($method, $_[1]{location}, %arg, recurse => $recurse - 1, $cb); 435 http_request ($method, $_[1]{location}, %arg, recurse => $recurse - 1, $cb);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines