--- trunk/Estraier.pm 2006/01/05 22:16:21 37 +++ trunk/Estraier.pm 2006/01/05 22:36:10 39 @@ -689,6 +689,11 @@ }; bless($self, $class); + if (@_) { + $self->{debug} = 1; + warn "## Node debug on\n"; + } + $self ? return $self : return undef; } @@ -784,7 +789,7 @@ my $status = -1; - warn $url; + warn "## $url\n"; $url = new URI($url); if ( @@ -837,10 +842,13 @@ return -1; } + warn "## headers:\n$headers\n" if ($self->{debug}); + print $sock $headers or carp "can't send headers to network:\n$headers\n" and return -1; if ($reqbody) { + warn "## request body:\n$headers\n" if ($self->{debug}); print $sock $$reqbody or carp "can't send request body to network:\n$$reqbody\n" and return -1; } @@ -850,21 +858,27 @@ my ($schema, $res_status, undef) = split(/ */, $line, 3); return if ($schema !~ /^HTTP/ || ! $res_status); - $self->{status} = $res_status; + $status = $res_status; + warn "## response status: $res_status\n" if ($self->{debug}); # skip rest of headers - do { + $line = <$sock>; + while ($line) { $line = <$sock>; - chomp($line); - } until ($line eq ''); + $line =~ s/[\r\n]+$//; + warn "## ", $line || 'NULL', " ##\n"; + }; # read body - my $len = 0; + $len = 0; do { $len = read($sock, my $buf, 8192); $$resbody .= $buf if ($resbody); } while ($len); + + warn "## response body:\n$$resbody\n" if ($self->{debug}); + return $status; }