Revert on system proxy : regressions appeared

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@220 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2008-12-08 14:35:16 +00:00
parent fa1400a59c
commit 87b37901ca
2 changed files with 3 additions and 34 deletions

View File

@ -10,6 +10,7 @@ import davmail.tray.DavGatewayTray;
import davmail.exchange.ExchangeSessionFactory;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.HttpConnection;
import org.apache.commons.httpclient.methods.GetMethod;
import java.io.BufferedReader;
@ -34,8 +35,6 @@ public class DavGateway {
* @param args command line parameter config file path
*/
public static void main(String[] args) {
// enable system proxy setup
System.setProperty("java.net.useSystemProxies","true");
if (args.length >= 1) {
Settings.setConfigFilePath(args[0]);
@ -113,7 +112,7 @@ public class DavGateway {
HttpClient httpClient = DavGatewayHttpClientFacade.getInstance();
GetMethod getMethod = new GetMethod("http://davmail.sourceforge.net/version.txt");
try {
httpClient.setConnectionTimeout(5000);
httpClient.setConnectionTimeout(1000);
int status = httpClient.executeMethod(getMethod);
if (status == HttpStatus.SC_OK) {
versionReader = new BufferedReader(new InputStreamReader(getMethod.getResponseBodyAsStream()));

View File

@ -6,9 +6,6 @@ import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.GetMethod;
import java.io.IOException;
import java.net.*;
import java.net.URI;
import java.util.List;
/**
* Create HttpClient instance according to DavGateway Settings
@ -49,39 +46,12 @@ public class DavGatewayHttpClientFacade {
httpClient.getState().setAuthenticationPreemptive(false);
boolean enableProxy = Settings.getBooleanProperty("davmail.enableProxy");
boolean systemProxy = Settings.getBooleanProperty("davmail.systemProxy");
String proxyHost = null;
int proxyPort = 0;
String proxyUser = null;
String proxyPassword = null;
if (systemProxy) {
String url = Settings.getProperty("davmail.url");
try {
List<Proxy> proxyList = ProxySelector.getDefault().select(
new URI(url));
// get first returned proxy
if (proxyList.size() > 0) {
Proxy proxy = proxyList.get(0);
if (proxy.equals(Proxy.NO_PROXY)) {
DavGatewayTray.debug("System proxy : direct connection");
} else {
InetSocketAddress addr = (InetSocketAddress) proxy.address();
proxyHost = addr.getHostName();
proxyPort = addr.getPort();
// no way to get credentials from system proxy
proxyUser = Settings.getProperty("davmail.proxyUser");
proxyPassword = Settings.getProperty("davmail.proxyPassword");
DavGatewayTray.debug("System proxy : " + proxyHost + ":" + proxyPort);
}
}
} catch (URISyntaxException e) {
DavGatewayTray.error(e);
}
} else if (enableProxy) {
if (enableProxy) {
proxyHost = Settings.getProperty("davmail.proxyHost");
proxyPort = Settings.getIntProperty("davmail.proxyPort");
proxyUser = Settings.getProperty("davmail.proxyUser");