+ } elsif ($state eq 'waitlocation') {
+ my ($path) = $msg =~ m|Location:\s*(.*)|;
+ if ($path) {
+ my $newconn;
+ my @uri = split m|/+|, $path;
+ if ($uri[0] eq 'http:') {
+ shift @uri;
+ my $host = shift @uri;
+ my $newpath = '/' . join('/', @uri);
+ $newpath .= '/' if $path =~ m|/$|;
+ $newconn = _getpost(ref $conn, $conn->{_assort}, $conn->{caller}, $host, 80, $newpath, @{$conn->{_asargs}});
+ } elsif ($path =~ m|^/|) {
+ $newconn = _getpost(ref $conn, $conn->{_assort}, $conn->{caller}, $conn->{peerhost}, $conn->{peerport}, $path, @{$conn->{_asargs}});
+ }
+ if ($newconn) {
+ # copy over any elements in $conn that are not in $newconn
+ while (my ($k,$v) = each %$conn) {
+ dbg("async: $state copying over $k -> \$newconn") if isdbg('async');
+ $newconn{$k} = $v unless exists $newconn{$k};
+ }
+ }
+ delete $conn->{on_disconnect};
+ $conn->disconnect;
+ }