2003/12/29 03:25:43
[org.ibex.core.git] / src / org / xwt / HTTP.java
index de013f0..a3525e4 100644 (file)
@@ -106,7 +106,7 @@ public class HTTP {
                 else doWebAuth(h, content == null ? "GET" : "POST");
                 
                 if (h.get("HTTP").equals("1.0") && h.get("content-length") == null) {
-                    if (Log.on) Log.log(this, "proxy returned an HTTP/1.0 reply with no content-length...");
+                    if (Log.on) Log.info(this, "proxy returned an HTTP/1.0 reply with no content-length...");
                     reset();
                 } else {
                     int cl = h.get("content-length") == null ? -1 : Integer.parseInt(h.get("content-length").toString());
@@ -177,11 +177,11 @@ public class HTTP {
     /** Attempts a direct connection */
     private Socket attemptDirect() {
         try {
-            if (Log.verbose) Log.log(this, "attempting to create unproxied socket to " +
+            if (Log.verbose) Log.info(this, "attempting to create unproxied socket to " +
                                      host + ":" + port + (ssl ? " [ssl]" : ""));
             return getSocket(host, port, ssl, true);
         } catch (IOException e) {
-            if (Log.on) Log.log(this, "exception in attemptDirect(): " + e);
+            if (Log.on) Log.info(this, "exception in attemptDirect(): " + e);
             return null;
         }
     }
@@ -189,7 +189,7 @@ public class HTTP {
     /** Attempts to use an HTTP proxy, employing the CONNECT method if HTTPS is requested */
     private Socket attemptHttpProxy(String proxyHost, int proxyPort) {
         try {
-            if (Log.verbose) Log.log(this, "attempting to create HTTP proxied socket using proxy " + proxyHost + ":" + proxyPort);
+            if (Log.verbose) Log.info(this, "attempting to create HTTP proxied socket using proxy " + proxyHost + ":" + proxyPort);
             Socket sock = getSocket(proxyHost, proxyPort, ssl, false);
 
             if (!ssl) {
@@ -208,7 +208,7 @@ public class HTTP {
             return sock;
 
         } catch (IOException e) {
-            if (Log.on) Log.log(this, "exception in attemptHttpProxy(): " + e);
+            if (Log.on) Log.info(this, "exception in attemptHttpProxy(): " + e);
             return null;
         }
     }
@@ -224,7 +224,7 @@ public class HTTP {
         InetAddress addr = null;
         try { addr = InetAddress.getByName(host); } catch (Exception e) { }
 
-        if (Log.verbose) Log.log(this, "attempting to create SOCKSv4" + (addr == null ? "" : "a") +
+        if (Log.verbose) Log.info(this, "attempting to create SOCKSv4" + (addr == null ? "" : "a") +
                                  " proxied socket using proxy " + proxyHost + ":" + proxyPort);
 
         try {
@@ -254,33 +254,33 @@ public class HTTP {
                 if (ssl) ((SSL)sock).negotiate();
                 return sock;
             }
-            if (Log.on) Log.log(this, "SOCKS server denied access, code " + (success & 0xff));
+            if (Log.on) Log.info(this, "SOCKS server denied access, code " + (success & 0xff));
             return null;
 
         } catch (IOException e) {
-            if (Log.on) Log.log(this, "exception in attemptSocksProxy(): " + e);
+            if (Log.on) Log.info(this, "exception in attemptSocksProxy(): " + e);
             return null;
         }
     }
 
     /** executes the PAC script and dispatches a call to one of the other attempt methods based on the result */
     private Socket attemptPAC(org.xwt.js.JS pacFunc) {
-        if (Log.verbose) Log.log(this, "evaluating PAC script");
+        if (Log.verbose) Log.info(this, "evaluating PAC script");
         String pac = null;
         try {
             org.xwt.js.JSArray args = new org.xwt.js.JSArray();
             Object obj = pacFunc.call(url.toString(), url.getHost(), null, null, 2);
-            if (Log.verbose) Log.log(this, "  PAC script returned \"" + obj + "\"");
+            if (Log.verbose) Log.info(this, "  PAC script returned \"" + obj + "\"");
             pac = obj.toString();
         } catch (Throwable e) {
-            if (Log.on) Log.log(this, "PAC script threw exception " + e);
+            if (Log.on) Log.info(this, "PAC script threw exception " + e);
             return null;
         }
 
         StringTokenizer st = new StringTokenizer(pac, ";", false);
         while (st.hasMoreTokens()) {
             String token = st.nextToken().trim();
-            if (Log.verbose) Log.log(this, "  trying \"" + token + "\"...");
+            if (Log.verbose) Log.info(this, "  trying \"" + token + "\"...");
             try {
                 Socket ret = null;
                 if (token.startsWith("DIRECT"))
@@ -293,10 +293,10 @@ public class HTTP {
                                             Integer.parseInt(token.substring(token.indexOf(':') + 1)));
                 if (ret != null) return ret;
             } catch (Throwable e) {
-                if (Log.on) Log.log(this, "attempt at \"" + token + "\" failed due to " + e + "; trying next token");
+                if (Log.on) Log.info(this, "attempt at \"" + token + "\" failed due to " + e + "; trying next token");
             }
         }
-        if (Log.on) Log.log(this, "all PAC results exhausted");
+        if (Log.on) Log.info(this, "all PAC results exhausted");
         return null;
     }
 
@@ -333,7 +333,7 @@ public class HTTP {
         path = this.url.getFile();
         if (port == -1) port = ssl ? 443 : 80;
         host = this.url.getHost();
-        if (Log.verbose) Log.log(this, "creating HTTP object for connection to " + host + ":" + port);
+        if (Log.verbose) Log.info(this, "creating HTTP object for connection to " + host + ":" + port);
 
         Proxy pi = Platform.detectProxy();
         OUTER: do {
@@ -414,13 +414,13 @@ public class HTTP {
     }
 
     private void doProxyAuth(Hashtable h0, String method) throws IOException {
-        if (Log.on) Log.log(this, "Proxy AuthChallenge: " + h0.get("proxy-authenticate"));
+        if (Log.on) Log.info(this, "Proxy AuthChallenge: " + h0.get("proxy-authenticate"));
         Hashtable h = parseAuthenticationChallenge(h0.get("proxy-authenticate").toString());
         String style = h.get("AUTHTYPE").toString();
         String realm = (String)h.get("realm");
 
         if (style.equals("NTLM") && Proxy.Authorization.authorization2 == null) {
-            Log.log(this, "Proxy identified itself as NTLM, sending Type 1 packet");
+            Log.info(this, "Proxy identified itself as NTLM, sending Type 1 packet");
             Proxy.Authorization.authorization2 = "NTLM " + Base64.encode(Proxy.NTLM.type1);
             return;
         }
@@ -449,7 +449,7 @@ public class HTTP {
                 "algorithm=MD5";
 
         } else if (style.equals("NTLM")) {
-            Log.log(this, "Proxy identified itself as NTLM, got Type 2 packet");
+            Log.info(this, "Proxy identified itself as NTLM, got Type 2 packet");
             byte[] type2 = Base64.decode(((String)h0.get("proxy-authenticate")).substring(5).trim());
             for(int i=0; i<type2.length; i += 4) {
                 String log = "";
@@ -457,7 +457,7 @@ public class HTTP {
                 if (i+1<type2.length) log += Integer.toString(type2[i+1] & 0xff, 16) + " ";
                 if (i+2<type2.length) log += Integer.toString(type2[i+2] & 0xff, 16) + " ";
                 if (i+3<type2.length) log += Integer.toString(type2[i+3] & 0xff, 16) + " ";
-                Log.log(this, log);
+                Log.info(this, log);
             }
             // FEATURE: need to keep the connection open between type1 and type3
             // FEATURE: finish this
@@ -720,15 +720,15 @@ public class HTTP {
                 String s = null;
                 String script = "";
                 while((s = br.readLine()) != null) script += s + "\n";
-                if (Log.on) Log.log(Proxy.class, "successfully retrieved WPAD PAC:");
-                if (Log.on) Log.log(Proxy.class, script);
+                if (Log.on) Log.info(Proxy.class, "successfully retrieved WPAD PAC:");
+                if (Log.on) Log.info(Proxy.class, script);
             
                 // MS CARP hack
                 Vector carpHosts = new Vector();
                 for(int i=0; i<script.length(); i++)
                     if (script.regionMatches(i, "new Node(", 0, 9)) {
                         String host = script.substring(i + 10, script.indexOf('\"', i + 11));
-                        if (Log.on) Log.log(Proxy.class, "Detected MS Proxy Server CARP Script, Host=" + host);
+                        if (Log.on) Log.info(Proxy.class, "Detected MS Proxy Server CARP Script, Host=" + host);
                         carpHosts.addElement(host);
                     }
                 if (carpHosts.size() > 0) {
@@ -736,8 +736,8 @@ public class HTTP {
                     for(int i=0; i<carpHosts.size(); i++)
                         script += "PROXY " + carpHosts.elementAt(i) + "; ";
                     script += "\";\n}";
-                    if (Log.on) Log.log(Proxy.class, "DeCARPed PAC script:");
-                    if (Log.on) Log.log(Proxy.class, script);
+                    if (Log.on) Log.info(Proxy.class, "DeCARPed PAC script:");
+                    if (Log.on) Log.info(Proxy.class, script);
                 }
 
                 JSFunction scr = JSFunction.fromReader("PAC script at " + url, 0, new StringReader(script));
@@ -745,16 +745,16 @@ public class HTTP {
                 return (JSFunction)proxyAutoConfigRootJSScope.get("FindProxyForURL");
             } catch (Exception e) {
                 if (Log.on) {
-                    Log.log(Platform.class, "WPAD detection failed due to:");
+                    Log.info(Platform.class, "WPAD detection failed due to:");
                     if (e instanceof JSExn) {
                         try {
                             org.xwt.js.JSArray arr = new org.xwt.js.JSArray();
                             arr.addElement(((JSExn)e).getObject());
                         } catch (Exception e2) {
-                            Log.log(Platform.class, e);
+                            Log.info(Platform.class, e);
                         }
                     }
-                    else Log.log(Platform.class, e);
+                    else Log.info(Platform.class, e);
                 }
                 return null;
             }
@@ -777,7 +777,7 @@ public class HTTP {
                 // a password, so we should reattempt authorization.
 
                 if (authorization != oldAuth) return;
-                if (Log.on) Log.log(Authorization.class, "displaying proxy authorization dialog");
+                if (Log.on) Log.info(Authorization.class, "displaying proxy authorization dialog");
                 Scheduler.add(new Scheduler.Task() {
                         public void perform() throws Exception {
                             Box b = new Box();
@@ -789,7 +789,7 @@ public class HTTP {
                     });
 
                 waitingForUser.block();
-                if (Log.on) Log.log(Authorization.class, "got proxy authorization info; re-attempting connection");
+                if (Log.on) Log.info(Authorization.class, "got proxy authorization info; re-attempting connection");
             }
         }
 
@@ -860,7 +860,7 @@ public class HTTP {
                     try {
                         return InetAddress.getLocalHost().getHostAddress();
                     } catch (UnknownHostException e) {
-                        if (Log.on) Log.log(this, "strange... host does not know its own address");
+                        if (Log.on) Log.info(this, "strange... host does not know its own address");
                         return null;
                     }
                 case "dnsDomainLevels":