LaBrea-Tarpit
view release on metacpan or search on metacpan
Parse an http server response into a hash of headers.
i.e. (representative, will vary)
rc => 200
msg => OK
date => Wed, 24 Apr 2002 21:46:30 GMT
server => Apache/1.3.22
protocol => HTTP/1.1
content-type => text/plain
content-length => 92
last-modified => Wed, 24 Apr 2002 21:46:34 GMT
expires => Wed, 24 Apr 2002 21:47:04 GMT
connection => close
content => (complete text buffer)
input: \$text_in, \%response
returns: true on success, %response filled
false on failure
};
return 'timeout, failed to get short response'
if $@ =~ /short_response TIMEOUT/;
return $@ if $@; # show other errors
return 'invalid short response, no data'
unless $buffer;
return $rsp->{rc} . ' ' . $rsp->{msg}
unless parse_http_response(\$buffer,$rsp);
return 'invalid content-type ' . $rsp->{'content-type'}
unless $rsp->{'content-type'} =~ m|text/plain|i;
%$cnt = split(/[=\n]/,$rsp->{content});
return 'invalid data in short response'
unless exists $cnt->{LaBrea} &&
exists $cnt->{Tarpit} &&
exists $cnt->{Report} &&
exists $cnt->{Util} &&
exists $cnt->{now} &&
exists $cnt->{tz} &&
exists $cnt->{threads} &&
$rv=parse_http_response(\$buffer,\%response);
Parse an http server response into a hash of headers.
i.e. (representative, will vary)
rc => 200
msg => OK
date => Wed, 24 Apr 2002 21:46:30 GMT
server => Apache/1.3.22
protocol => HTTP/1.1
content-type => text/plain
content-length => 92
last-modified => Wed, 24 Apr 2002 21:46:34 GMT
expires => Wed, 24 Apr 2002 21:47:04 GMT
connection => close
content => (complete text buffer)
input: \$text_in, \%response
returns: true on success, %response filled
false on failure
( run in 1.741 second using v1.01-cache-2.11-cpan-524268b4103 )