Added support for basic authentification in post
authorplehegar
Fri, 26 Aug 2011 11:39:26 -0400
changeset 108 09bfee98db20
parent 107 f69944b2a39b
child 109 70322101593e
Added support for basic authentification in post
src/main/resources/scripts/Utils.js
--- a/src/main/resources/scripts/Utils.js	Fri Aug 26 10:04:06 2011 -0400
+++ b/src/main/resources/scripts/Utils.js	Fri Aug 26 11:39:26 2011 -0400
@@ -6,7 +6,6 @@
   // wait for at least 2 consecutive GPS data before declaring the GPS ready
   gps_max_errors : 2
   
-
 };
 
 var Util = {
@@ -147,6 +146,11 @@
    		xhr.setRequestHeader("Content-Type", (!!resource.contentType)? resource.contentType : "application/octet-stream");
     	xhr.setRequestHeader("Content-Length", resource.data.length);
     	xhr.setRequestHeader("Accept", "text/plain");
+    	if (!!resource.userId && !!resource.passwd) {
+    		// we do basic auth
+    		xhr.setRequestHeader("Authorization",
+    							Base64.encode('Basic ' + resource.userId + ':' + resource.passwd));
+    	}
     	xhr.send(resource.data);
     } catch (e) {
       Util.log("Failed to send to server " + e);