From the thin guide for HTTP::Headers :
A multi-valued field will be returned as separate values ββin the context of the list and will be combined with "," as a separator in a scalar context.
and this is the list context:
print ($response->header('Content-length'))
So $response->header() returns both the Content-length headers to the list, and the result, essentially:
print join('', 43215, 43215)
You can use the kork $response->content_length() approach or grab all Content-length headers in an array and use the first as the length:
my @lengths = $response->header('Content-length'); my $length = $lengths[0];
If you get multiple Content-length headers, and they are different, then someone is very confused.
source share