From 205c1ac3b6133f7623d789fab52d7bd38a31e2dc Mon Sep 17 00:00:00 2001 From: Roland Schwingel Date: Mon, 10 Aug 2015 17:08:28 +0200 Subject: [PATCH 1/6] Fix startup on IE10 --- Objective-J/CFHTTPRequest.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) mode change 100644 => 100755 Objective-J/CFHTTPRequest.js diff --git a/Objective-J/CFHTTPRequest.js b/Objective-J/CFHTTPRequest.js old mode 100644 new mode 100755 index 0d34667f2..000a0d92f --- a/Objective-J/CFHTTPRequest.js +++ b/Objective-J/CFHTTPRequest.js @@ -104,7 +104,7 @@ GLOBAL(CFHTTPRequest) = function() this._nativeRequest = new NativeRequest(); // by default, all requests will assume that credentials should not be sent. - this._nativeRequest.withCredentials = false; + this._withCredentials = false; var self = this; this._stateChangeHandler = function() @@ -221,13 +221,18 @@ CFHTTPRequest.prototype.overrideMimeType = function(/*String*/ aMimeType) CFHTTPRequest.prototype.open = function(/*String*/ aMethod, /*String*/ aURL, /*Boolean*/ isAsynchronous, /*String*/ aUser, /*String*/ aPassword) { + var retval; + this._isOpen = true; this._URL = aURL; this._async = isAsynchronous; this._method = aMethod; this._user = aUser; this._password = aPassword; - return this._nativeRequest.open(aMethod, aURL, isAsynchronous, aUser, aPassword); + retval = this._nativeRequest.open(aMethod, aURL, isAsynchronous, aUser, aPassword); + this._nativeRequest.withCredentials = this._withCredentials; + + return retval; }; CFHTTPRequest.prototype.send = function(/*Object*/ aBody) @@ -279,12 +284,14 @@ CFHTTPRequest.prototype.removeEventListener = function(/*String*/ anEventName, / CFHTTPRequest.prototype.setWithCredentials = function(/*Boolean*/ willSendWithCredentials) { - this._nativeRequest.withCredentials = willSendWithCredentials; + this._withCredentials = willSendWithCredentials + if (this._isOpen) + this._nativeRequest.withCredentials = willSendWithCredentials; }; CFHTTPRequest.prototype.withCredentials = function() { - return this._nativeRequest.withCredentials; + return this._withCredentials; }; function determineAndDispatchHTTPRequestEvents(/*CFHTTPRequest*/ aRequest) From 73e13fee37d290b3d9a55f4b4376815b62c7ad9d Mon Sep 17 00:00:00 2001 From: Roland Schwingel Date: Tue, 11 Aug 2015 09:03:21 +0200 Subject: [PATCH 2/6] Fix for startup on IE10. Reformatted patch --- Objective-J/CFHTTPRequest.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Objective-J/CFHTTPRequest.js b/Objective-J/CFHTTPRequest.js index 000a0d92f..b5c48e537 100755 --- a/Objective-J/CFHTTPRequest.js +++ b/Objective-J/CFHTTPRequest.js @@ -221,7 +221,7 @@ CFHTTPRequest.prototype.overrideMimeType = function(/*String*/ aMimeType) CFHTTPRequest.prototype.open = function(/*String*/ aMethod, /*String*/ aURL, /*Boolean*/ isAsynchronous, /*String*/ aUser, /*String*/ aPassword) { - var retval; + var retval; this._isOpen = true; this._URL = aURL; @@ -284,9 +284,9 @@ CFHTTPRequest.prototype.removeEventListener = function(/*String*/ anEventName, / CFHTTPRequest.prototype.setWithCredentials = function(/*Boolean*/ willSendWithCredentials) { - this._withCredentials = willSendWithCredentials - if (this._isOpen) - this._nativeRequest.withCredentials = willSendWithCredentials; + this._withCredentials = willSendWithCredentials + if (this._isOpen) + this._nativeRequest.withCredentials = willSendWithCredentials; }; CFHTTPRequest.prototype.withCredentials = function() From 2ab918625966ddf3bc390a327ddc6c47e042b9f6 Mon Sep 17 00:00:00 2001 From: Roland Schwingel Date: Thu, 20 Aug 2015 14:52:19 +0200 Subject: [PATCH 3/6] Fix Chrome warning when using synchronous XHR requests --- Objective-J/CFHTTPRequest.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objective-J/CFHTTPRequest.js b/Objective-J/CFHTTPRequest.js index 47ac34910..c98eedaca 100755 --- a/Objective-J/CFHTTPRequest.js +++ b/Objective-J/CFHTTPRequest.js @@ -246,7 +246,8 @@ CFHTTPRequest.prototype.open = function(/*String*/ aMethod, /*String*/ aURL, /*B this._user = aUser; this._password = aPassword; retval = this._nativeRequest.open(aMethod, aURL, isAsynchronous, aUser, aPassword); - this._nativeRequest.withCredentials = this._withCredentials; + if (this._async) + this._nativeRequest.withCredentials = this._withCredentials; return retval; }; @@ -304,7 +305,7 @@ CFHTTPRequest.prototype.removeEventListener = function(/*String*/ anEventName, / CFHTTPRequest.prototype.setWithCredentials = function(/*Boolean*/ willSendWithCredentials) { this._withCredentials = willSendWithCredentials - if (this._isOpen) + if (this._isOpen && this._async) this._nativeRequest.withCredentials = willSendWithCredentials; }; From 1eb12d4fa001d30980462cca69f8f9a84d256bfa Mon Sep 17 00:00:00 2001 From: Roland Schwingel Date: Thu, 20 Aug 2015 14:57:28 +0200 Subject: [PATCH 4/6] Damned... corrected formatting --- Objective-J/CFHTTPRequest.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Objective-J/CFHTTPRequest.js b/Objective-J/CFHTTPRequest.js index c98eedaca..4a77cc796 100755 --- a/Objective-J/CFHTTPRequest.js +++ b/Objective-J/CFHTTPRequest.js @@ -246,8 +246,8 @@ CFHTTPRequest.prototype.open = function(/*String*/ aMethod, /*String*/ aURL, /*B this._user = aUser; this._password = aPassword; retval = this._nativeRequest.open(aMethod, aURL, isAsynchronous, aUser, aPassword); - if (this._async) - this._nativeRequest.withCredentials = this._withCredentials; + if (this._async) + this._nativeRequest.withCredentials = this._withCredentials; return retval; }; From 55181cec8ce36201bd7373bdb6e80b5007701cdc Mon Sep 17 00:00:00 2001 From: Roland Schwingel Date: Thu, 17 Sep 2015 14:45:35 +0200 Subject: [PATCH 5/6] Set timeout in XHR requests AFTER they are opened to get them to work with IE --- Objective-J/CFHTTPRequest.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Objective-J/CFHTTPRequest.js b/Objective-J/CFHTTPRequest.js index 4a77cc796..dbf3ac704 100755 --- a/Objective-J/CFHTTPRequest.js +++ b/Objective-J/CFHTTPRequest.js @@ -105,6 +105,7 @@ GLOBAL(CFHTTPRequest) = function() // by default, all requests will assume that credentials should not be sent. this._withCredentials = false; + this._timeout = 60000; var self = this; this._stateChangeHandler = function() @@ -217,12 +218,14 @@ CFHTTPRequest.prototype.getResponseHeader = function(/*String*/ aHeader) CFHTTPRequest.prototype.setTimeout = function(/*int*/ aTimeout) { - this._nativeRequest.timeout = aTimeout; + this._timeout = aTimeout; + if (this._isOpen) + this._nativeRequest.timeout = aTimeout; }; CFHTTPRequest.prototype.getTimeout = function(/*int*/ aTimeout) { - return this._nativeRequest.timeout; + return this._timeout; }; CFHTTPRequest.prototype.getAllResponseHeaders = function() @@ -248,6 +251,7 @@ CFHTTPRequest.prototype.open = function(/*String*/ aMethod, /*String*/ aURL, /*B retval = this._nativeRequest.open(aMethod, aURL, isAsynchronous, aUser, aPassword); if (this._async) this._nativeRequest.withCredentials = this._withCredentials; + this._nativeRequest.timeout = this._timeout; return retval; }; From dd4de9822fe51e88a801e5755b433094a835204d Mon Sep 17 00:00:00 2001 From: Roland Schwingel Date: Wed, 23 Sep 2015 19:16:20 +0200 Subject: [PATCH 6/6] Adjustment for (a)sync request with timeout to work on IE and other browsers --- Objective-J/CFHTTPRequest.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Objective-J/CFHTTPRequest.js b/Objective-J/CFHTTPRequest.js index dbf3ac704..4e54b064d 100755 --- a/Objective-J/CFHTTPRequest.js +++ b/Objective-J/CFHTTPRequest.js @@ -248,10 +248,13 @@ CFHTTPRequest.prototype.open = function(/*String*/ aMethod, /*String*/ aURL, /*B this._method = aMethod; this._user = aUser; this._password = aPassword; + retval = this._nativeRequest.open(aMethod, aURL, isAsynchronous, aUser, aPassword); if (this._async) + { this._nativeRequest.withCredentials = this._withCredentials; - this._nativeRequest.timeout = this._timeout; + this._nativeRequest.timeout = this._timeout; + } return retval; };