[dancer-users] Problems Directly printing to Apache2::RequestRec buffer with dancer

Brian Brandes Brian.C.Brandes at gmail.com
Wed Apr 30 19:24:32 BST 2014

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

And then I make a request to it...

==== Begin Request Dump ====
GET http://localhost/buffertest
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

=== 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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20140430/553e3b81/attachment.html>

More information about the dancer-users mailing list