X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FHTTP.java;h=9190f8f14945d2ef80fa72a1632e32d714cc45f7;hb=7e9239a7088d4cd772a31a76e1a53e1c681638bc;hp=8d7ffda56f971ca4ae84511e60174c0b087463ed;hpb=2ccad2219888c9942f62ae8b4d4207f655690948;p=org.ibex.core.git diff --git a/src/org/xwt/HTTP.java b/src/org/xwt/HTTP.java index 8d7ffda..9190f8f 100644 --- a/src/org/xwt/HTTP.java +++ b/src/org/xwt/HTTP.java @@ -1,4 +1,4 @@ -// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL] +// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL] package org.xwt; import java.net.*; @@ -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