Re: XHR responseArrayBuffer attribute: suggestion to replace "asBlob" with "responseType"

Chris Marrin wrote:
> On Oct 25, 2010, at 4:07 PM, Jeremy Orlow wrote:
> 
>> ...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.
>>
>> The parameter would be added to .open() (after username and password).  This means you'd have to pass in undefined for both in most uses.  And it has the disadvantage you mentioned for #2.
> 
> It could be done in a separate call (setResponseType(in DOMString type)), to avoid that.

This seems like the most extensible and future compatible option, it 
also simplifies the interface.

Out of interest, would there be a way in which a callback could be used 
to set the response type *after* headers have been received, or to pass 
in some structured map of content-type to response-type settings?

The use-case I'm looking at (and would actually benefit from) is that 
often I send accept headers when following links to resources on the 
web, in some cases based on the content type I'd want to set it to Text, 
XML or Bytes, the point though is that there's no way you could define a 
single logic for this, nor I, and I'd need to provide a function to do 
this selection. Also note that the preference change based on context, 
sometimes I want the same media type as Text, other times and XML, other 
times as Bytes - the only way to handle this optimally (that I can see) 
would be by executing a callback, or by passing a map structure 
containing preferences for each content type.

Best,

Nathan

Received on Wednesday, 27 October 2010 00:06:53 UTC