Subject: | Not safe headers reading |
It seems for me, that lines below may cause potential problem.
---------------------------------
$s->write_request(
GET => "/flows?filter=$flows" =>
Authorization => 'Basic ' . MIME::Base64::encode($auth),
Accept => 'application/json',
);
my ($code, $message, %headers) = $s->read_response_headers;
die "Unable to connect: $message"
unless $code == 200;
---------------------------------
You are trying to read headers only once. But read_response_headers()
may return empty list (as documented) if full header not yet received.
So, it will be better to check return value and try again when socket
will become ready for reading.