You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2012/02/22 09:15:23 UTC
[29/29] wp7 commit: Fixed WrappedXHR with headers
Fixed WrappedXHR with headers
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/commit/5c2310ed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/tree/5c2310ed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/diff/5c2310ed
Branch: refs/heads/master
Commit: 5c2310edb0dfaf19f64cc53c0fea4e6fd080959b
Parents: 85ca662
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Fri Feb 3 15:45:45 2012 -0800
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Fri Feb 3 15:45:45 2012 -0800
----------------------------------------------------------------------
framework/js/PGXHR.js | 61 +++++++++++++++++++++++++++++++------------
1 files changed, 44 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/5c2310ed/framework/js/PGXHR.js
----------------------------------------------------------------------
diff --git a/framework/js/PGXHR.js b/framework/js/PGXHR.js
index 5742f71..f1f86a4 100644
--- a/framework/js/PGXHR.js
+++ b/framework/js/PGXHR.js
@@ -1,17 +1,4 @@
-/*
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
+
/**
* @author purplecabbage
*/
@@ -37,7 +24,7 @@
var aliasXHR = win.XMLHttpRequest;
win.XMLHttpRequest = function(){};
-
+ win.XMLHttpRequest.noConflict = aliasXHR;
win.XMLHttpRequest.UNSENT = 0;
win.XMLHttpRequest.OPENED = 1;
win.XMLHttpRequest.HEADERS_RECEIVED = 2;
@@ -56,9 +43,13 @@
onreadystatechange:null,
readyState:0,
_url:"",
+ timeout:0,
+ withCredentials:false,
+ _requestHeaders:null,
open:function(reqType,uri,isAsync,user,password)
{
- console.log("XMLHttpRequest.open " + uri);
+ console.log("XMLHttpRequest.open ::: " + uri);
+
if(uri && uri.indexOf("http") == 0)
{
if(!this.wrappedXHR)
@@ -66,6 +57,34 @@
this.wrappedXHR = new aliasXHR();
var self = this;
+ // timeout
+ if(this.timeout > 0)
+ {
+ this.wrappedXHR.timeout = this.timeout;
+ }
+ Object.defineProperty( this, "timeout", {
+ set: function(val) {
+ this.wrappedXHR.timeout = val;
+ },
+ get:function() {
+ return this.wrappedXHR.timeout;
+ }});
+
+
+
+ if(this.withCredentials)
+ {
+ this.wrappedXHR.withCredentials = this.withCredentials;
+ }
+ Object.defineProperty( this, "withCredentials", {
+ set: function(val) {
+ this.wrappedXHR.withCredentials = val;
+ },
+ get:function() {
+ return this.wrappedXHR.withCredentials;
+ }});
+
+
Object.defineProperty( this, "status", { get: function() {
return this.wrappedXHR.status;
}});
@@ -120,6 +139,13 @@
this.onreadystatechange();
}
},
+ setRequestHeader:function(header,value)
+ {
+ if(this.wrappedXHR)
+ {
+ this.wrappedXHR.setRequestHeader(header,value);
+ }
+ },
getResponseHeader:function(header)
{
return this.wrappedXHR ? this.wrappedXHR.getResponseHeader(header) : "";
@@ -175,4 +201,5 @@
},false);// addEventListener
-})(window,document);
\ No newline at end of file
+})(window,document);
+