1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 03:02:22 -05:00

Improve system proxies and move item logging

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1727 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2011-07-05 06:55:41 +00:00
parent c7b8da9c8d
commit a67d16beef

View File

@ -38,6 +38,7 @@ import org.apache.jackrabbit.webdav.DavException;
import org.apache.jackrabbit.webdav.MultiStatusResponse; import org.apache.jackrabbit.webdav.MultiStatusResponse;
import org.apache.jackrabbit.webdav.client.methods.CopyMethod; import org.apache.jackrabbit.webdav.client.methods.CopyMethod;
import org.apache.jackrabbit.webdav.client.methods.DavMethodBase; import org.apache.jackrabbit.webdav.client.methods.DavMethodBase;
import org.apache.jackrabbit.webdav.client.methods.MoveMethod;
import org.apache.jackrabbit.webdav.client.methods.PropFindMethod; import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
import org.apache.jackrabbit.webdav.property.DavPropertyNameSet; import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -167,7 +168,7 @@ public final class DavGatewayHttpClientFacade {
// get proxy for url from system settings // get proxy for url from system settings
System.setProperty("java.net.useSystemProxies", "true"); System.setProperty("java.net.useSystemProxies", "true");
try { try {
List<Proxy> proxyList = getDefaultProxySelector().select(new java.net.URI(url)); List<Proxy> proxyList = getProxyForURI(new java.net.URI(url));
if (!proxyList.isEmpty() && proxyList.get(0).address() != null) { if (!proxyList.isEmpty() && proxyList.get(0).address() != null) {
InetSocketAddress inetSocketAddress = (InetSocketAddress) proxyList.get(0).address(); InetSocketAddress inetSocketAddress = (InetSocketAddress) proxyList.get(0).address();
proxyHost = inetSocketAddress.getHostName(); proxyHost = inetSocketAddress.getHostName();
@ -213,13 +214,14 @@ public final class DavGatewayHttpClientFacade {
/** /**
* Retrieve Proxy Selector * Retrieve Proxy Selector
* *
* @param uri target uri
* @return proxy selector * @return proxy selector
*/ */
private static ProxySelector getDefaultProxySelector() { private static List<Proxy> getProxyForURI(java.net.URI uri) {
LOGGER.debug("Loading system proxy settings..."); LOGGER.debug("getProxyForURI(" + uri + ')');
ProxySelector proxySelector = ProxySelector.getDefault(); List<Proxy> proxies = ProxySelector.getDefault().select(uri);
LOGGER.debug("Loaded system proxy settings"); LOGGER.debug("got system proxies:" + proxies);
return proxySelector; return proxies;
} }
@ -641,7 +643,7 @@ public final class DavGatewayHttpClientFacade {
message.append(status).append(' ').append(method.getStatusText()); message.append(status).append(' ').append(method.getStatusText());
try { try {
message.append(" at ").append(method.getURI().getURI()); message.append(" at ").append(method.getURI().getURI());
if (method instanceof CopyMethod) { if (method instanceof CopyMethod || method instanceof MoveMethod) {
message.append(" to ").append(method.getRequestHeader("Destination")); message.append(" to ").append(method.getRequestHeader("Destination"));
} }
} catch (URIException e) { } catch (URIException e) {
@ -665,6 +667,7 @@ public final class DavGatewayHttpClientFacade {
/** /**
* Test if the method response is gzip encoded * Test if the method response is gzip encoded
*
* @param method http method * @param method http method
* @return true if response is gzip encoded * @return true if response is gzip encoded
*/ */