method = new OptionsMethod(request.getUrl());
} else {
throw new IllegalStateException(String.format("Invalid Method", methodName));
}
ProxyServer proxyServer = request.getProxyServer() != null ? request.getProxyServer() : config.getProxyServer();
boolean avoidProxy = ProxyUtils.avoidProxy( proxyServer, request );
if (!avoidProxy) {
if (proxyServer.getPrincipal() != null) {
Credentials defaultcreds = new UsernamePasswordCredentials(proxyServer.getPrincipal(), proxyServer.getPassword());
client.getState().setCredentials(new AuthScope(null, -1, AuthScope.ANY_REALM), defaultcreds);
}
ProxyHost proxyHost = proxyServer == null ? null : new ProxyHost(proxyServer.getHost(), proxyServer.getPort());
client.getHostConfiguration().setProxyHost(proxyHost);
}
method.setFollowRedirects(false);
if ((request.getCookies() != null) && !request.getCookies().isEmpty()) {