+ host = this.url.getHost();
+ if (Log.on) Log.log(this, "creating HTTP object for connection to " + host + ":" + port);
+ addHeader("Host", host); // host header is always sent verbatim
+ if (!skipResolveCheck) host = resolveAndCheckIfFirewalled(host); // might have to use the strict IP if behind a proxy
+
+ ProxyInfo pi = Platform.detectProxy();
+ if (sock == null && pi != null && pi.proxyAutoConfigFunction != null) sock = attemptPAC(pi.proxyAutoConfigFunction);
+ if (sock == null && pi != null && ssl && pi.httpsProxyHost != null) sock = attemptHttpProxy(pi.httpsProxyHost, pi.httpsProxyPort);
+ if (sock == null && pi != null && pi.httpProxyHost != null) sock = attemptHttpProxy(pi.httpProxyHost, pi.httpProxyPort);
+ if (sock == null && pi != null && pi.socksProxyHost != null) sock = attemptSocksProxy(pi.socksProxyHost, pi.socksProxyPort);
+ if (sock == null) sock = attemptDirect();
+ if (sock == null) throw new HTTPException("all socket creation attempts have failed");
+ sock.setTcpNoDelay(true);
+ }
+
+
+ // Safeguarded DNS Resolver ///////////////////////////////////////////////////////////////////////////
+
+ /**
+ * resolves the hostname and returns it as a string in the form "x.y.z.w", except for the special case "xmlrpc.xwt.org".
+ * @throws HTTPException if the host falls within a firewalled netblock
+ */
+ private String resolveAndCheckIfFirewalled(String host) throws HTTPException {
+
+ // special case
+ if (host.equals("xmlrpc.xwt.org")) return host;
+
+ // cached
+ if (resolvedHosts.get(host) != null) return (String)resolvedHosts.get(host);
+
+ if (Log.on) Log.log(this, " resolveAndCheckIfFirewalled: resolving " + host);
+
+ // resolve using DNS