Re: [XHR] support for streaming data

On Mon, Aug 8, 2011 at 9:36 PM, David Flanagan <dflanagan@mozilla.com> wrote:
> On 8/8/11 5:13 PM, Jonas Sicking wrote:
>>
>> To solve this I propose we add two new values to .responseType:
>> "streaming-text" and "streaming-arraybuffer".
>
> I think this would be a very useful feature.  I only have naming nits:
>
> 1) What do you think of "textstream" instead of "streaming-text"?  Similarly
> for arraybufferstream (or ArrayBufferStream)

That works too. I was actually even thinking "chunked-text" or
"chunked-arraybuffer" since this is very different from a real Stream
object. (I'm sure we'll eventually add a .responseType="stream").

> 2) Is there any possible use case for streaming blobs?  If so, then I'd say
> that the streaming vs. non-streaming issue is orthogonal to the data type
> issue and there should be something like responseMethod = "stream" instead
> of responseType = "streaming-text"

I don't think there's a use case for streaming Blobs. The point of a
blob is to be able to get large pieces of data which you either don't
want to hold in memory all at once, or which you aren't going to use
immediately and so you don't want to keep it in memory.

The point of streamed XHR is to receive data as soon as it's available
so that you can process it right away. This also means that you're
likely going to get the data in pretty small chunks. Hence the use
cases for streaming are basically the direct opposite of the ones for
blobs.

It also doesn't make sense for parsed formats, like XML, HTML or, if
we add it in the future, JSON, to use streaming. It's unlikely that
the contents of those can be delivered in chunks, and so it's better
that we'll just incrementally parse, which is already what happens.

/ Jonas

Received on Thursday, 11 August 2011 00:05:11 UTC