if (port == -1) port = ssl ? 443 : 80;
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
+ addHeader("Host", host); // host header is always sent verbatim
+ if (!skipResolveCheck) 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 && 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);
}
* 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 {
+ private void resolveAndCheckIfFirewalled(String host) throws HTTPException {
// special case
- if (host.equals("xmlrpc.xwt.org")) return host;
+ if (host.equals("xmlrpc.xwt.org")) return;
// cached
- if (resolvedHosts.get(host) != null) return (String)resolvedHosts.get(host);
+ if (resolvedHosts.get(host) != null) return;
if (Log.on) Log.log(this, " resolveAndCheckIfFirewalled: resolving " + host);
(quadbyte[0] == 192 && quadbyte[1] == 168) ||
(quadbyte[0] == 172 && (quadbyte[1] & 0xF0) == 16)) && !addr.equals(Main.originAddr))
throw new HTTPException("security violation: " + host + " [" + addr.getHostAddress() + "] is in a firewalled netblock");
- return addr.getHostAddress();
+ return;
} catch (UnknownHostException uhe) { }
// resolve using xmlrpc.xwt.org
Object ret = new XMLRPC("http://xmlrpc.xwt.org/RPC2/", "dns.resolve").call(new Object[] { host });
if (ret == null || !(ret instanceof String)) throw new Exception(" xmlrpc.xwt.org returned non-String: " + ret);
resolvedHosts.put(host, ret);
- return (String)ret;
+ return;
} catch (Throwable e) {
throw new HTTPException("exception while attempting to use xmlrpc.xwt.org to resolve " + host + ": " + e);
}
} else {
PrintWriter pw = new PrintWriter(new OutputStreamWriter(sock.getOutputStream()));
pw.print("GET " + path + " HTTP/1.0\r\n");
- System.out.print("GET " + path + " HTTP/1.0\r\n");
pw.print("User-Agent: XWT\r\n");
pw.print(headers);
pw.print("\r\n");
in = new BufferedInputStream(sock.getInputStream());
// we can't use a BufferedReader directly on the input stream,
- // since it will buffer beyond the end of the headers
+ // since it will buffer past the end of the headers
byte[] buf = new byte[4096];
int buflen = 0;
while(true) {
/** the PAC script */
public Function proxyAutoConfigFunction = null;
+ // this method has been disabled because it was causing problems -- some domains are set up so that *.foo.com resolves
+ // to a single IP, for any value of *. If the client's home domain is foo.com, then xwt-proxy-httpHost will resolve erroneously.
public static ProxyInfo detectProxyViaManual() {
+ return null;
+ /*
try {
// continue iff one of the two resolves
try { InetAddress.getByName("xwt-proxy-httpHost"); }
if (Log.on) Log.log(Platform.class, "xwt-proxy-* detection failed due to: " + e);
return null;
}
+ */
}
// FIXME: search up from default domain