Skip to content

Commit 4feb8c1

Browse files
committed
kludge for #66: Fall back to XMLHTTPRequest if Fetch API doesn't work
1 parent 6c55671 commit 4feb8c1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

plugins/SocketPlugin.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,16 @@ function SocketPlugin() {
143143
console.warn('Retrying with CORS proxy: ' + url);
144144
fetch(url, init)
145145
.then(function(res) {
146+
console.log('Success: ' + url);
146147
thisHandle._handleFetchAPIResponse(res);
147148
plugin.needProxy.add(thisHandle._hostAndPort());
148149
})
149150
.catch(function (e) {
150-
thisHandle._otherEndClosed();
151-
console.warn(e);
151+
// KLUDGE! This is just a workaround for a broken
152+
// proxy server - we should remove it when
153+
// crossorigin.me is fixed
154+
console.warn('Fetch API failed, retrying with XMLHttpRequest');
155+
thisHandle._performXMLHTTPRequest(targetURL, httpMethod, data, requestLines);
152156
});
153157
});
154158
},
@@ -208,6 +212,7 @@ function SocketPlugin() {
208212
retry.open(httpMethod, url);
209213
retry.responseType = httpRequest.responseType;
210214
retry.onload = function(oEvent) {
215+
console.log('Success: ' + url);
211216
thisHandle._handleXMLHTTPResponse(this);
212217
plugin.needProxy.add(thisHandle._hostAndPort());
213218
};

0 commit comments

Comments
 (0)