use proxies util class to determine if proxy settings should be used

This commit is contained in:
Sebastian Sdorra
2012-12-09 14:55:43 +01:00
parent 5de4ee9fc0
commit 485e3485fc
2 changed files with 25 additions and 24 deletions

View File

@@ -271,8 +271,7 @@ public class URLHttpClient implements HttpClient
* @param password * @param password
*/ */
private void appendBasicAuthHeader(HttpURLConnection connection, private void appendBasicAuthHeader(HttpURLConnection connection,
String header, String username, String header, String username, String password)
String password)
{ {
if (Util.isNotEmpty(username) || Util.isNotEmpty(password)) if (Util.isNotEmpty(username) || Util.isNotEmpty(password))
{ {
@@ -533,20 +532,21 @@ public class URLHttpClient implements HttpClient
{ {
if (request == null) if (request == null)
{ {
// TODO improve // TODO improve
request = new HttpRequest(url.toExternalForm()); request = new HttpRequest(url.toExternalForm());
} }
HttpURLConnection connection = null; HttpURLConnection connection = null;
if (!request.isIgnoreProxySettings() && configuration.isEnableProxy()) if (!request.isIgnoreProxySettings()
&& Proxies.isEnabled(configuration, url))
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
logger.debug("fetch '{}' using proxy {}:{}", logger.debug("fetch '{}' using proxy {}:{}",
new Object[] { url.toExternalForm(), new Object[] { url.toExternalForm(),
configuration.getProxyServer(), configuration.getProxyServer(), configuration.getProxyPort() });
configuration.getProxyPort() });
} }
SocketAddress address = SocketAddress address =
@@ -595,8 +595,8 @@ public class URLHttpClient implements HttpClient
connection.setRequestProperty(HEADER_ACCEPT_ENCODING, connection.setRequestProperty(HEADER_ACCEPT_ENCODING,
HEADER_ACCEPT_ENCODING_VALUE); HEADER_ACCEPT_ENCODING_VALUE);
connection.setRequestProperty( connection.setRequestProperty(HEADER_USERAGENT,
HEADER_USERAGENT, HEADER_USERAGENT_VALUE.concat(context.getVersion())); HEADER_USERAGENT_VALUE.concat(context.getVersion()));
String username = configuration.getProxyUser(); String username = configuration.getProxyUser();
String password = configuration.getProxyPassword(); String password = configuration.getProxyPassword();

View File

@@ -84,6 +84,7 @@ import java.util.Set;
import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller; import javax.xml.bind.Marshaller;
import sonia.scm.net.Proxies;
/** /**
* *
@@ -215,7 +216,7 @@ public class AetherPluginHandler
RemoteRepository rr = new RemoteRepository(repository.getId(), "default", RemoteRepository rr = new RemoteRepository(repository.getId(), "default",
repository.getUrl()); repository.getUrl());
if (configuration.isEnableProxy()) if (Proxies.isEnabled(configuration, rr.getHost()))
{ {
Proxy proxy = DefaultProxySelector.createProxy(configuration); Proxy proxy = DefaultProxySelector.createProxy(configuration);