private OutboundRequest nextRequest(final Constraints.Distilled distilled)
throws IOException
{
HttpSettings settings = getHttpSettings();
String phost = settings.getProxyHost(host);
boolean usingProxy = (phost.length() != 0);
int pport;
boolean ppersist;
// If looking for a connection through an HTTP proxy, and if the
// pingProxyConnectionTimeout has passed, then ping the server
// endpoint to verify that the endpoint is alive and reachable.
// This reduces the likelihood that a server endpoint having
// terminated or having become unreachable won't be noticed
// until after some or all of the data destined for the server
// has already been sent to the proxy.
if (!usingProxy) {
pport = -1;
ppersist = true;
} else {
pport = settings.getProxyPort();
ppersist = !settings.getDisableProxyPersistentConnections();
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkConnect(host, port);
}
long now = System.currentTimeMillis();
if (settings.getPingProxyConnections() &&
now - timeLastVerified >
settings.getPingProxyConnectionTimeout())
{
Object obj = connectionAction(distilled, phost, pport, ppersist,
new ConnectionAction() {
public Object run(Connection conn)
throws IOException