提交 74fa62be 编写于 作者: L Laurence Rowe

Use same condition in Body and Request for choosing responseType.

Chrome will error on access to xhr.responseText when xhr.responseType is set to something other than 'text'. Everything that supports Blob should support XHR2.
上级 77dd2e61
......@@ -69,20 +69,20 @@
body.bodyUsed = true
}
var blobSupport = self.FileReader && (function() {
try {
new Blob();
return true
} catch(e) {
return false
}
})();
function Body() {
this._body = null
this.bodyUsed = false
var blobSupport = (function() {
try {
new Blob();
return true
} catch(e) {
return false
}
})();
if (blobSupport && self.FileReader) {
if (blobSupport) {
this.arrayBuffer = function() {
var rejected = consumed(this)
if (rejected) {
......@@ -209,7 +209,7 @@
headers: headers(xhr),
url: xhr.responseURL || xhr.getResponseHeader('X-Request-URL')
}
resolve(new Response('responseType' in xhr ? xhr.response: xhr.responseText, options))
resolve(new Response(blobSupport ? xhr.response: xhr.responseText, options))
}
xhr.onerror = function() {
......@@ -217,7 +217,7 @@
}
xhr.open(self.method, self.url)
if ('responseType' in xhr) {
if (blobSupport) {
xhr.responseType = 'blob'
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册