After some hundred plus emails the WebApps WG finally settled on a design for getting access to octet data in the response of a request made with XMLHttpRequest. At least, I hope we did. The design is not as author friendly as it could have been, but I think it will work reasonably well, and it addresses the concerns about excess memory usage. According to Peter an experimental implementation landed in WebKit.
There are two new attributes:
responseType you indicate the type you want the response entity body to be in and with
response you access it.
responseType takes what will eventually become a string enumeration type. The empty string (default value), "
document", and "
blob" are the allowed values for now. In the future synchronous access to octet data will be added, once TC39 has either vetted
ArrayBuffer or replaced it with something better.
responseType is the empty string,
responseXML will both work (backwards compatible, yay), and
response will be the same as
responseText. When it is "
responseXML will throw and the rest returns a string. When it is "
responseText will throw and the rest returns a
Document or null. When it is anything else — for now this is only "
blob" — both
responseXML will throw. The
responseType member can be set up until just after all the HTTP headers have been received. From that point on it is fixed.