diff --git a/Objective-J/CFHTTPRequest.js b/Objective-J/CFHTTPRequest.js old mode 100644 new mode 100755 index 051044fdb..f658c84fc --- a/Objective-J/CFHTTPRequest.js +++ b/Objective-J/CFHTTPRequest.js @@ -104,7 +104,8 @@ 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; + 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() @@ -237,13 +240,23 @@ 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); + if (this._async) + { + this._nativeRequest.withCredentials = this._withCredentials; + this._nativeRequest.timeout = this._timeout; + } + + return retval; }; CFHTTPRequest.prototype.send = function(/*Object*/ aBody) @@ -298,12 +311,14 @@ CFHTTPRequest.prototype.removeEventListener = function(/*String*/ anEventName, / CFHTTPRequest.prototype.setWithCredentials = function(/*Boolean*/ willSendWithCredentials) { - this._nativeRequest.withCredentials = willSendWithCredentials; + this._withCredentials = willSendWithCredentials + if (this._isOpen && this._async) + this._nativeRequest.withCredentials = willSendWithCredentials; }; CFHTTPRequest.prototype.withCredentials = function() { - return this._nativeRequest.withCredentials; + return this._withCredentials; }; CFHTTPRequest.prototype.isTimeoutRequest = function()