Skip to content

Commit

Permalink
Merge pull request socketio#385 from mixu/upstream/fix-xhr-check
Browse files Browse the repository at this point in the history
Fix XHR.check, which was throwing an error and causing non-IE browsers to fall back to JSONP
  • Loading branch information
rauchg committed Mar 27, 2012
2 parents 53b5f3e + 6f80ef1 commit dce9685
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/transports/xhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @api public
*/

exports.XHR = XHR;

/**
Expand Down Expand Up @@ -129,7 +129,7 @@
/**
* Disconnects the established `XHR` connection.
*
* @returns {Transport}
* @returns {Transport}
* @api public
*/

Expand Down Expand Up @@ -187,7 +187,11 @@

XHR.check = function (socket, xdomain) {
try {
if (io.util.request(xdomain)) {
var request = io.util.request(xdomain),
usesXDomReq = (global.XDomainRequest && request instanceof XDomainRequest),
socketProtocol = (socket && socket.options && socket.options.secure ? 'https:' : 'http:'),
isXProtocol = (socketProtocol != global.location.protocol);
if (request && !(usesXDomReq && isXProtocol)) {
return true;
}
} catch(e) {}
Expand All @@ -196,8 +200,8 @@
};

/**
* Check if the XHR transport supports corss domain requests.
*
* Check if the XHR transport supports cross domain requests.
*
* @returns {Boolean}
* @api public
*/
Expand Down

0 comments on commit dce9685

Please sign in to comment.