-
Notifications
You must be signed in to change notification settings - Fork 512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XHR Level 2 responseType of arrayBuffer and Blob #2433
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,11 +74,21 @@ var Request = this.Request = new Class({ | |
if (progressSupport) xhr.onprogress = xhr.onloadstart = empty; | ||
clearTimeout(this.timer); | ||
|
||
this.response = {text: this.xhr.responseText || '', xml: this.xhr.responseXML}; | ||
if (this.options.isSuccess.call(this, this.status)) | ||
this.success(this.response.text, this.response.xml); | ||
else | ||
this.failure(); | ||
if (this.options.responseType | ||
&& (this.options.responseType == 'arraybuffer' || this.options.responseType == 'blob') ){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just put it on one line. Also there is an erroneous space at |
||
this.response = {}; | ||
this.response[this.options.responseType] = this.xhr.response || ''; | ||
if (this.options.isSuccess.call(this, this.status)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add curly brackets around ifs. |
||
this.success(this.response[this.options.responseType]); | ||
else | ||
this.failure(); | ||
} else { | ||
this.response = {text: this.xhr.responseText || '', xml: this.xhr.responseXML}; | ||
if (this.options.isSuccess.call(this, this.status)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. idem. |
||
this.success(this.response.text, this.response.xml); | ||
else | ||
this.failure(); | ||
} | ||
}, | ||
|
||
isSuccess: function(){ | ||
|
@@ -91,6 +101,7 @@ var Request = this.Request = new Class({ | |
}, | ||
|
||
processScripts: function(text){ | ||
if (typeof text != 'string') return text; | ||
if (this.options.evalResponse || (/(ecma|java)script/).test(this.getHeader('Content-type'))) return Browser.exec(text); | ||
return text.stripScripts(this.options.evalScripts); | ||
}, | ||
|
@@ -198,7 +209,7 @@ var Request = this.Request = new Class({ | |
|
||
xhr.open(method.toUpperCase(), url, this.options.async, this.options.user, this.options.password); | ||
if (this.options.user && 'withCredentials' in xhr) xhr.withCredentials = true; | ||
|
||
if (this.options.responseType) xhr.responseType = this.options.responseType; | ||
xhr.onreadystatechange = this.onStateChange.bind(this); | ||
|
||
Object.each(this.headers, function(value, key){ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the extra spaces between
:
and'get'
.