Skip to content

Commit 7c6b1d9

Browse files
committed
Check on status 304 and add Content-Type header
Looked into jQuery lib and found their XHR also checks on a 304 status (Not Modified) Added to success condition Content-Type header added to also tie in with original jQuery version of github.js
1 parent c60f2dc commit 7c6b1d9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

github.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
xhr.open(method, API_URL + path);
2020
xhr.onreadystatechange = function () {
2121
if (this.readyState == 4) {
22-
if (this.status >= 200 && this.status < 300) {
22+
if (this.status >= 200 && this.status < 300 || this.status === 304) {
2323
cb(null, raw ? this.responseText : JSON.parse(this.responseText));
2424
} else {
2525
cb(this.status);
2626
}
2727
}
2828
}
2929
xhr.setRequestHeader('Accept','application/vnd.github.raw');
30+
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
3031
if (
3132
(options.auth == 'oauth' && options.token) ||
3233
(options.auth == 'basic' && options.username && options.password)

0 commit comments

Comments
 (0)