[html5] XHR Questions
gomer at gomert-consulting.com
Fri Mar 18 23:29:20 PDT 2016
Thanks for your response.
I apologize if I am misusing the term "blob". The application I am trying to support makes sequential requests to a remote HTTP server for binary objects (ISO BMFF files, in fact). Because of the way the objects are generated, each object is delivered in chunked mode, with the delivery spread over time. I want the application to be able to consume the chunks of each response as they arrive, rather than waiting for the entire response to arrive before consuming any of it.
In the August 2009 version of the XMLHttpRequest() specification, this was possible. The responseBody arrived as a ByteArray, and the application could access the ByteArray at any time (with a partial response if the status is LOADING, and with the full response when the status is DONE).
For some reason, which I still don't understand, this capability was taken out by the time of the August 2011 version. In that version incremental consumption was only enabled for "text" type responses, not for "document" or "any" type responses.
When I first raised this question on help at lists.whatwg.org, someone suggested that Streams would be a better alternative. I looked into that and found that (a) there would be a pretty steep learning curve in order to use Streams, (b) quite a few definitions would be required to set up the Streams framework on the client side, and (c) whereas XMLHttpRequest() is pretty mature and well supported by all the major browsers at this point, Streams are not.
Since no one seems to know why the XMLHttpRequest() specification was changed to take away the incremental consumption capability for binary files, it seems unlikely it will be changed back any time soon, if at all (even though the current situation is a violation of the spirit of the specifications regarding support for chunked encoding in RFC 7230). Therefore, it appears that a proprietary solution based on a WebSocket will need to be implemented for the next couple of years at least, until Streams are mature and well supported.
In fact, even then a proprietary solution to get Streams from a remote server to an application's browser context might be required. The Streams specification appears to assume that everything is happening locally. I guess one could put a local "Streams" wrapper around the WebSocket interface, but the advantages of that over a pure proprietary solution are not clear.
Best regards, Gomer Thomas
Gomer Thomas Consulting, LLC
9810 132nd St NE
Arlington, WA 98223
From: Anne van Kesteren [mailto:annevk at annevk.nl]
Sent: Friday, March 18, 2016 12:28 AM
To: Gomer Thomas <gomer at gomert-consulting.com>
Cc: Domenic Denicola <d at domenic.me>; help at lists.whatwg.org
Subject: Re: [html5] XHR Questions
On Thu, Mar 17, 2016 at 9:15 PM, Gomer Thomas <gomer at gomert-consulting.com> wrote:
> Hi Domenic,
> By the way, the question is not why support for chunked
> responses to HTTP requests was not added in the first place for blobs.
> That capability was included in the August 2009 specification of
> XMLHttpRequest(). Thus, the question is why was it taken out later?
Blobs are fixed size. Allocating a new blob each time the server transmits a bit more data would be quite bad design. Streams is what we want here.
(Not sure if I'm subscribed to help so this might not make it to the list.)
More information about the Help