Are long polling responses considered?

Topics: Web Api
Jul 15, 2011 at 12:47 PM
Edited Jul 15, 2011 at 12:49 PM

I am wondering if there is any guidance or may be it's planned to support long polling responses. Something like Twitter StreamingAPI (without pub/sub stuff).

My take does not work. It just write everything as as single response.

public class StreamingContent : HttpContent
{            
    protected override Task SerializeToStreamAsync(Stream stream, TransportContext context)
    {
        throw new NotImplementedException();
    }

    protected override void SerializeToStream(Stream stream, TransportContext context)
    {
        for (var i = 0; i < 3; i++)
        {
            var buff = Encoding.UTF8.GetBytes("Sync #" + i + "\r\n");
            stream.Write(buff, 0, buff.Length);
            stream.Flush(); // Implementation is empty
            Thread.Sleep(3000);
        }                
    }

    protected override bool TryComputeLength(out long length)
    {
        length = -1;
        return false;
    }
}