setting secure on xul calls by default
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 9 Aug 2006 15:30:50 +0000 (15:30 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 9 Aug 2006 15:30:50 +0000 (15:30 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5404 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/common/js/RemoteRequest.js
Open-ILS/web/opac/common/js/opac_utils.js

index c43257e..e289081 100644 (file)
@@ -78,6 +78,9 @@ function RemoteRequest( service, method ) {
        this.id                 = service + method + Math.random();
        this.cancelled = false;
 
+       this.setSecure(false);
+       if(isXUL()) this.setSecure(true);
+
        _allrequests[this.id] = this;
 
        var i = 2;
@@ -218,26 +221,24 @@ RemoteRequest.prototype.send = function(blocking) {
        /* determine the xmlhttp server dynamically */
        var url = location.protocol + "//" + location.host + "/" + XML_HTTP_GATEWAY;
 
-       if(isXUL() && XML_HTTP_SERVER) {
-               if(this.secure || url.match(/^https:/) )
-                       url =   "https://" + XML_HTTP_SERVER + "/" + XML_HTTP_GATEWAY;
-               else
-                       url =   "http://" + XML_HTTP_SERVER + "/" + XML_HTTP_GATEWAY;
+       if(isXUL()) {
+               netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
+               if( this.secure ) url = url.replace(/http/, 'https');
+               else url = url.replace(/https/, 'http');
        }
 
-       /* this number could be a lot higher.. */
-       var whole = url + this.param_string + 1;
-
        var data = null;
        if( this.type == 'GET' ) url +=  "?" + this.param_string; 
 
+       if(isXUL() && this.secure ) dump('SECURE = true\n');
+
        try {
 
                if(blocking) this.xmlhttp.open(this.type, url, false);
                else this.xmlhttp.open(this.type, url, true);
                
        } catch(E) {
-               alert("Fatal error opening XMLHTTPRequest for URL:\n" + url + '\n');
+               alert("Fatal error opening XMLHTTPRequest for URL:\n" + url + '\n' + E);
                return;
        }
 
index a41231f..37dfefb 100644 (file)
@@ -15,6 +15,11 @@ function Request(type) {
        this.request = new RemoteRequest(s[0], s[1]);
        var p = [];
 
+       if(isXUL()) {
+               if(!location.href.match(/https:\/\//))
+                       this.request.setSecure(false);
+       }
+
        for( var x = 1; x!= arguments.length; x++ ) {
                p.push(arguments[x]);
                this.request.addParam(arguments[x]);