I'm trying to write a a perl-based webserver using Twiggy::Server
(which means a plack app).
I want to respond to a request (coming from an ajax call on a webpage) for some data by running some possibly time-consuming subroutine which generates the data and then turns it into a JSON string for returning to the client webpage.
You can see a cut-down test version of my server here: http://pastebin.com/iNaDTVwL
That example shows the problem I'm facing with my current implementation; using AnyEvent::ForkManager
to do the non-blocking part of things results in truncation of the 'big' json response.
This document would answer my questions perfectly (and better explains what I'm trying to do): https://github.com/jjn1056/Example-PlackStreamingAndNonblocking ... if it was finished. I'm just missing the 'proper' way of doing non-blocking, instead of using AnyEvent::ForkManager
which seems like a bit of a hack.