Subject: | Zero length content header causes request to not post back |
The test case attached GET's a url with Content-Length: 0 header.
Zero length content is unchecked in HTTP.pm poco_weeble_io_read. The return at the bottom of the if block near line 464 has the effect of not posting back the response.
If checks are added, and that return moved, then line 53 of HTTPHead.pm (return [undef];) causes $input to be undef on the next call to poco_weeble_io_read.
#!/usr/bin/perl
# test case for Client::HTTP no content bug
use POE qw(Component::Client::HTTP);
use HTTP::Request::Common qw(GET);
POE::Component::Client::HTTP->spawn( Alias => 'ua' );
POE::Session->create(
inline_states => {
_start => sub {
# get url that has 0 length content
$_[KERNEL]->post(
'ua', # posts to the 'ua' alias
'request', # posts to ua's 'request' state
'response', # which of our states will receive the response
GET 'http://xantus.org/no_content.html'
);
print "request sent\n";
},
response => sub {
my ($request_packet, $response_packet) = @_[ARG0, ARG1];
# HTTP::Request
my $request_object = $request_packet->[0];
# HTTP::Response
my $response_object = $response_packet->[0];
print(
"*" x 78, "\n",
"*** my request:\n",
"-" x 78, "\n",
$request_object->as_string(),
"*" x 78, "\n",
"*** their response:\n",
"-" x 78, "\n",
$response_object->as_string(),
);
print "*" x 78, "\n";
},
_stop => sub { print "session stopped. You should have recieved a response.\n" },
}
);
$poe_kernel->run();