X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2FHTTP.java;h=10da62b2cb0a42f39eb813f2cef58105a5a149de;hp=7f6f248b29b0974390f56ea6475c9b100bee13d2;hb=a41252ba1e0f5dd90100aa2064c011268809c038;hpb=a6c4f7b784acf2269c33188982b0d479cc11a0f4 diff --git a/src/org/ibex/HTTP.java b/src/org/ibex/HTTP.java index 7f6f248..10da62b 100644 --- a/src/org/ibex/HTTP.java +++ b/src/org/ibex/HTTP.java @@ -41,7 +41,7 @@ public class HTTP { // Instance Data /////////////////////////////////////////////////////////////////////////////////////////////// final String originalUrl; ///< the URL as passed to the original constructor; this is never changed - URL url = null; ///< the URL to connect to; this is munged when the url is parsed */ + String url = null; ///< the URL to connect to; this is munged when the url is parsed */ String host = null; ///< the host to connect to int port = -1; ///< the port to connect on boolean ssl = false; ///< true if SSL (HTTPS) should be used @@ -270,7 +270,7 @@ public class HTTP { if (Log.verbose) Log.info(this, "evaluating PAC script"); String pac = null; try { - Object obj = pacFunc.call(url.toString(), url.getHost(), null, null, 2); + Object obj = pacFunc.call(url, host, null, null, 2); if (Log.verbose) Log.info(this, " PAC script returned \"" + obj + "\""); pac = obj.toString(); } catch (Throwable e) { @@ -322,18 +322,22 @@ public class HTTP { } if (url.startsWith("https:")) { - this.url = new URL("http" + url.substring(5)); ssl = true; } else if (!url.startsWith("http:")) { - throw new MalformedURLException("HTTP only supports http/https urls"); + throw new IOException("HTTP only supports http/https urls"); + } + if (url.indexOf("://") == -1) throw new IOException("URLs must contain a ://"); + String temphost = url.substring(url.indexOf("://") + 1); + path = temphost.substring(temphost.indexOf('/')); + temphost = temphost.substring(0, temphost.indexOf('/')); + if (temphost.indexOf(':') != -1) { + port = Integer.parseInt(temphost.substring(temphost.indexOf(':')+1)); + temphost = temphost.substring(0, temphost.indexOf(':')); } else { - this.url = new URL(url); + port = ssl ? 443 : 80; } - if (!skipResolveCheck) resolveAndCheckIfFirewalled(this.url.getHost()); - port = this.url.getPort(); - path = this.url.getFile(); - if (port == -1) port = ssl ? 443 : 80; - host = this.url.getHost(); + if (!skipResolveCheck) resolveAndCheckIfFirewalled(temphost); + host = temphost; if (Log.verbose) Log.info(this, "creating HTTP object for connection to " + host + ":" + port); Proxy pi = Platform.detectProxy();