- From: Boris Zbarsky <bzbarsky@MIT.EDU>
- Date: Mon, 25 Oct 2010 18:33:35 -0400
- To: Chris Rogers <crogers@google.com>
- CC: Web Applications Working Group WG <public-webapps@w3.org>, Anne van Kesteren <annevk@opera.com>, Eric Uhrhane <ericu@google.com>, michaeln@google.com, Darin Fisher <darin@google.com>, Alexey Proskuryakov <ap@webkit.org>, Chris Marrin <cmarrin@apple.com>, Geoffrey Garen <ggaren@apple.com>, jorlow@google.com
On 10/25/10 6:21 PM, Chris Rogers wrote: > People are concerned that it would require keeping two copies of the > data around (raw bytes, and unicode text version) since it's unknown > up-front whether "responseText", or "responseArrayBuffer" will be > accessed. Note that Gecko does exactly that, and we've seen no problems with it... It's very rare to have really large XHR bodies, for what it's worth. > This approach does seem a little strange because of the mutually > exclusive nature of the access. However, it seems that it would be hard > to come up for a reasonable use case where both the raw bytes *and* the > text would be needed for the same XHR. You could have a situation where a library dispatches the XHR for you and always looks at the text for some reason (libraries tend to do that sort of thing) while you actually want the bytes. In general, this approach seems really fragile and hostile to web developers. > 2. Darin Fisher has suggested this approach: Add an "asArrayBuffer" > attribute (similar to "asBlob") which *must* be set before sending the > request if there will be a subsequent access of the > "responseArrayBuffer" attribute. This make it impossible to decide whether to look at the text or the bytes based on the content-type of the response (unless you allow setting the attribute in some early-enough onStateChange callback _and_ libraries expose XHRs in that early a state to consumers); having that ability seems like a desirable feature. > 3. Get rid of the "asBlob" attribute and add a new "responseType" > attribute which could be: > "Text" <--- this is the default > "XML" > "Bytes" > ... other types yet to be defined I'm not sure I follow this proposal. > I can accept any of the proposed solutions and would like to hear what > others think about these or other approaches. How about: 4) Make things easy to use for authors; that means supporting responseText and responseArrayBuffer, with access to both on the same XHR object without weird restrictions and without clairvoyance required on the part of the author. If UAs feel that they don't want to keep both copies of the data in memory on a permanent basis, they can optimize this by dropping the responseText (on a timer or via a low-memory detection mechanism, or in various other ways) and regenerating it from the raw bytes as needed. ? The other suggestions really feel like a case of overoptimizing for simplicity and ease of creation of UA code at the expense of authors. Sometimes that's warranted, but in this case the UA code needed to produce sane behavior is really just not that complicated or hard.... -Boris
Received on Monday, 25 October 2010 22:34:12 UTC