I'm using Transfer-Encoding: chunked
to write an HTTP response.
The response is split into pieces via the following:
my $template = "a$buffer_size" x int(length($response)/$buffer_size) . 'a*';
foreach my $buffer (unpack $template, $response){
...
}
This works fine when the content type is text/html
, but it is corrupting binary data, such as application/pdf
.
Can unpack
be used to split binary data into equal lengths?