- if ($state eq 'waitreply') {
- # look at the reply code and decide whether it is a success
- my ($http, $code, $ascii) = $msg =~ m|(HTTP/\d\.\d)\s+(\d+)\s+(.*)|;
- if ($code == 200) {
- # success
- $conn->{state} = 'waitblank';
- } elsif ($code == 302) {
- # redirect
- $conn->{state} = 'waitlocation';
- } else {
- $dxchan->send("$code $ascii");
- $conn->disconnect;
- }
- } elsif ($state eq 'waitlocation') {
- my ($path) = $msg =~ m|Location:\s*(.*)|;
- if ($path) {
- my @uri = split m|/+|, $path;
- if ($uri[0] eq 'http:') {
- shift @uri;
- my $host = shift @uri;
- my $newpath = '/' . join('/', @uri);
- $newpath .= '/' if $path =~ m|/$|;
- _getpost(ref $conn, $conn->{asyncsort}, $conn->{caller}, $host, 80, $newpath, @{$conn->{asyncargs}});
- } elsif ($path =~ m|^/|) {
- _getpost(ref $conn, $conn->{asyncsort}, $conn->{caller}, $conn->{peerhost}, $conn->{peerport}, $path,
- @{$conn->{asyncargs}});
- }
- delete $conn->{on_disconnect};
- $conn->disconnect;
- }
- } elsif ($state eq 'waitblank') {
- unless ($msg) {
- $conn->{state} = 'indata';
- }
- } elsif ($conn->{state} eq 'indata') {
- if (my $filter = $conn->{filter}) {
+ my @lines = split qr{\r?\n}, $tx->res->body;
+
+ foreach my $msg(@lines) {
+ dbg("AsyncMsg: $conn->{_asstate} $msg") if isdbg('async');
+
+ if (my $filter = $conn->{_asfilter}) {