[web-devel] Upcoming WAI change: flushing

Michael Snoyman michael at snoyman.com
Thu Jan 26 09:02:48 CET 2012

On Thu, Jan 26, 2012 at 9:29 AM, Kazu Yamamoto <kazu at iij.ad.jp> wrote:
> Hello,
>> I've just pushed a relatively minor change to the WAI spec to Github,
>> which ties off the last hole in the specification I'm aware of. One
>> annoyance in creating streaming responses is the issue of flushing. By
>> using Builders, it's more difficult to make a truly streaming,
>> realtime app, as the server will wait until a buffer is filled before
>> sending any data to the client. This is actually a very easy problem
>> to solve. blaze-builder provides a value called `flush` that forces
>> the buffer to be sent, even if it's not full.
> This sounds good.
> I updated all necessary libraries and tried to compile wai-app-file-cgi.
> I got the following error.
> ----
> Couldn't match expected type `Flush Builder'
>            with actual type `Builder'
> Expected type: Source IO (Flush Builder)
>  Actual type: Source IO Builder
> In the third argument of `ResponseSource', namely `src'
> In the second argument of `($)', namely
>  `(ResponseSource st hdr' src)'
> ----
> I don't understand how to fix. Are there any example implementations
> for proxy?

Without seeing the code in question, I would try:
    ResponseSource st hdr' $ fmap Chunk src

This would create a stream without any flushing, which is what the
previous behavior supported.


More information about the web-devel mailing list