response
memberAfter 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
and response
. With 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), "text
", "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.
When responseType
is the empty string, responseText
and responseXML
will both work (backwards compatible, yay), and response
will be the same as responseText
. When it is "text
" responseXML
will throw and the rest returns a string. When it is "document
" responseText
will throw and the rest returns a Document
or null. When it is anything else — for now this is only "blob
" — both responseText
and 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.