I'm retrofitting Dancer onto an existing perl application of mine. However, some of the code, for large report generations, will directly print to the web buffer. This is resulting in nothing come back in my response. E.g, with this route handler:
get '/buffertest' => sub {
my $r = request->input_handle;
$r->print("hello world");
# ref $r == Apache2::RequestRec
return;
};
And then I make a request to it...
==== Begin Request Dump ====
Content-Type: application/json
=== End Request Dump ====
... , the response won't come back:
==== Begin Response Dump ====
HTTP/1.1 200 OK
Connection: close
Date: Wed, 30 Apr 2014 16:37:19 GMT
Server: Apache
Vary: Accept-Encoding,User-Agent
Content-Length: 0
Content-Type: text/html; charset=utf-8
Client-Date: Wed, 30 Apr 2014 16:37:20 GMT
Client-Response-Num: 1
P3P: CP="CAO PSA OUR"
=== End Response Dump ====
IF however, I do something like enable autoflushing ($|=1) then I will get "hello world" back, but that feels like a very brutal hack. Is there an equivalent way to flush response in Dancer?