689 |
}; |
}; |
690 |
bless($self, $class); |
bless($self, $class); |
691 |
|
|
692 |
|
if (@_) { |
693 |
|
$self->{debug} = 1; |
694 |
|
warn "## Node debug on\n"; |
695 |
|
} |
696 |
|
|
697 |
$self ? return $self : return undef; |
$self ? return $self : return undef; |
698 |
} |
} |
699 |
|
|
842 |
return -1; |
return -1; |
843 |
} |
} |
844 |
|
|
845 |
|
warn "## headers:\n$headers\n" if ($self->{debug}); |
846 |
|
|
847 |
print $sock $headers or |
print $sock $headers or |
848 |
carp "can't send headers to network:\n$headers\n" and return -1; |
carp "can't send headers to network:\n$headers\n" and return -1; |
849 |
|
|
850 |
if ($reqbody) { |
if ($reqbody) { |
851 |
|
warn "## request body:\n$headers\n" if ($self->{debug}); |
852 |
print $sock $$reqbody or |
print $sock $$reqbody or |
853 |
carp "can't send request body to network:\n$$reqbody\n" and return -1; |
carp "can't send request body to network:\n$$reqbody\n" and return -1; |
854 |
} |
} |
858 |
my ($schema, $res_status, undef) = split(/ */, $line, 3); |
my ($schema, $res_status, undef) = split(/ */, $line, 3); |
859 |
return if ($schema !~ /^HTTP/ || ! $res_status); |
return if ($schema !~ /^HTTP/ || ! $res_status); |
860 |
|
|
861 |
$self->{status} = $res_status; |
$status = $res_status; |
862 |
|
warn "## response status: $res_status\n" if ($self->{debug}); |
863 |
|
|
864 |
# skip rest of headers |
# skip rest of headers |
865 |
$line = <$sock>; |
$line = <$sock>; |
876 |
$$resbody .= $buf if ($resbody); |
$$resbody .= $buf if ($resbody); |
877 |
} while ($len); |
} while ($len); |
878 |
|
|
879 |
|
|
880 |
|
warn "## response body:\n$$resbody\n" if ($self->{debug}); |
881 |
|
|
882 |
return $status; |
return $status; |
883 |
} |
} |
884 |
|
|