Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2009-01-17 22:04:55 +0000
committerslewis2009-01-17 22:04:55 +0000
commit3cd179417b1051da3309ba58c03dc405cee51b39 (patch)
treee09f3956a9c16a03b55ff535fbe3c295db55b88e
parent91e8ab33899d8060b3155b357369a1c6e0964d54 (diff)
downloadorg.eclipse.ecf-20090117-1403.tar.gz
org.eclipse.ecf-20090117-1403.tar.xz
org.eclipse.ecf-20090117-1403.zip
Additions for tracing for httpclient provider https://bugs.eclipse.org/bugs/show_bug.cgi?id=245336. Also added httpclient-based file browse.v20090117-1403
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/.options16
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/plugin.xml14
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/internal/provider/filetransfer/httpclient/DebugOptions.java23
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientBrowseFileTransferFactory.java70
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientFileSystemBrowser.java223
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java72
6 files changed, 407 insertions, 11 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/.options b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/.options
new file mode 100644
index 000000000..03cb57bda
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/.options
@@ -0,0 +1,16 @@
+# Debugging options for the org.eclipse.ecf.provider.filetransfer.httpclient plug-in
+
+# Turn on general debugging for the org.eclipse.ecf.provider.filetransfer.httpclient plug-in
+org.eclipse.ecf.provider.filetransfer.httpclient/debug=true
+org.eclipse.ecf.provider.filetransfer.httpclient/debug/filter = *
+org.eclipse.ecf.provider.filetransfer.httpclient/debug/flag = true
+
+# Trace when exceptions are caught
+org.eclipse.ecf.provider.filetransfer.httpclient/debug/exceptions/catching=false
+# Trace when exceptions are thrown
+org.eclipse.ecf.provider.filetransfer.httpclient/debug/exceptions/throwing=false
+
+# Trace when methods are entered
+org.eclipse.ecf.provider.filetransfer.httpclient/debug/methods/entering=false
+# Trace when methods are exited
+org.eclipse.ecf.provider.filetransfer.httpclient/debug/methods/exiting=false
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/plugin.xml b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/plugin.xml
index 64901cc4b..292bb6e49 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/plugin.xml
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/plugin.xml
@@ -15,4 +15,18 @@
</retrieveFileTransferProtocolFactory>
</extension>
+ <extension
+ point="org.eclipse.ecf.provider.filetransfer.browseFileTransferProtocolFactory">
+ <browseFileTransferProtocolFactory
+ class="org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientBrowseFileTransferFactory"
+ protocol="http"
+ priority="50">
+ </browseFileTransferProtocolFactory>
+ <browseFileTransferProtocolFactory
+ class="org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientBrowseFileTransferFactory"
+ protocol="https"
+ priority="50">
+ </browseFileTransferProtocolFactory>
+ </extension>
+
</plugin>
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/internal/provider/filetransfer/httpclient/DebugOptions.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/internal/provider/filetransfer/httpclient/DebugOptions.java
new file mode 100644
index 000000000..d0b0274a6
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/internal/provider/filetransfer/httpclient/DebugOptions.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.internal.provider.filetransfer.httpclient;
+
+public interface DebugOptions {
+
+ public static final String DEBUG = Activator.PLUGIN_ID + "/debug"; //$NON-NLS-1$
+
+ public static final String EXCEPTIONS_CATCHING = DEBUG + "/exceptions/catching"; //$NON-NLS-1$
+
+ public static final String EXCEPTIONS_THROWING = DEBUG + "/exceptions/throwing"; //$NON-NLS-1$
+
+ public static final String METHODS_ENTERING = DEBUG + "/methods/entering"; //$NON-NLS-1$
+
+ public static final String METHODS_EXITING = DEBUG + "/methods/exiting"; //$NON-NLS-1$
+
+}
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientBrowseFileTransferFactory.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientBrowseFileTransferFactory.java
new file mode 100644
index 000000000..0b4fc9e79
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientBrowseFileTransferFactory.java
@@ -0,0 +1,70 @@
+/****************************************************************************
+ * Copyright (c) 2007 IBM, Composent Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+package org.eclipse.ecf.provider.filetransfer.httpclient;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.ecf.core.identity.IDFactory;
+import org.eclipse.ecf.core.identity.Namespace;
+import org.eclipse.ecf.core.security.IConnectContext;
+import org.eclipse.ecf.core.util.Proxy;
+import org.eclipse.ecf.filetransfer.*;
+import org.eclipse.ecf.filetransfer.identity.IFileID;
+import org.eclipse.ecf.filetransfer.service.IRemoteFileSystemBrowser;
+import org.eclipse.ecf.filetransfer.service.IRemoteFileSystemBrowserFactory;
+import org.eclipse.ecf.provider.filetransfer.identity.FileTransferNamespace;
+import org.eclipse.osgi.util.NLS;
+
+public class HttpClientBrowseFileTransferFactory implements IRemoteFileSystemBrowserFactory {
+
+ public IRemoteFileSystemBrowser newInstance() {
+ return new IRemoteFileSystemBrowser() {
+
+ private Proxy proxy;
+ private IConnectContext connectContext;
+
+ public Namespace getBrowseNamespace() {
+ return IDFactory.getDefault().getNamespaceByName(FileTransferNamespace.PROTOCOL);
+ }
+
+ public IRemoteFileSystemRequest sendBrowseRequest(IFileID directoryOrFileId, IRemoteFileSystemListener listener) throws RemoteFileSystemException {
+ Assert.isNotNull(directoryOrFileId);
+ Assert.isNotNull(listener);
+ URL url;
+ try {
+ url = directoryOrFileId.getURL();
+ } catch (final MalformedURLException e) {
+ throw new RemoteFileSystemException(NLS.bind("Exception creating URL for {0}", directoryOrFileId)); //$NON-NLS-1$
+ }
+
+ HttpClientFileSystemBrowser browser = new HttpClientFileSystemBrowser(new HttpClient(new MultiThreadedHttpConnectionManager()), directoryOrFileId, listener, url, connectContext, proxy);
+ return browser.sendBrowseRequest();
+ }
+
+ public void setConnectContextForAuthentication(IConnectContext connectContext) {
+ this.connectContext = connectContext;
+ }
+
+ public void setProxy(Proxy proxy) {
+ this.proxy = proxy;
+ }
+
+ public Object getAdapter(Class adapter) {
+ return null;
+ }
+
+ };
+
+ }
+}
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientFileSystemBrowser.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientFileSystemBrowser.java
new file mode 100644
index 000000000..18541e081
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientFileSystemBrowser.java
@@ -0,0 +1,223 @@
+/****************************************************************************
+ * Copyright (c) 2008 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.provider.filetransfer.httpclient;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import javax.security.auth.login.LoginException;
+import org.apache.commons.httpclient.*;
+import org.apache.commons.httpclient.auth.*;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.protocol.Protocol;
+import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
+import org.apache.commons.httpclient.util.DateUtil;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.ecf.core.security.*;
+import org.eclipse.ecf.core.util.*;
+import org.eclipse.ecf.filetransfer.IRemoteFile;
+import org.eclipse.ecf.filetransfer.IRemoteFileSystemListener;
+import org.eclipse.ecf.filetransfer.identity.IFileID;
+import org.eclipse.ecf.internal.provider.filetransfer.httpclient.*;
+import org.eclipse.ecf.provider.filetransfer.browse.AbstractFileSystemBrowser;
+import org.eclipse.ecf.provider.filetransfer.browse.URLRemoteFile;
+import org.eclipse.ecf.provider.filetransfer.util.JREProxyHelper;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ *
+ */
+public class HttpClientFileSystemBrowser extends AbstractFileSystemBrowser {
+
+ protected static final int DEFAULT_CONNECTION_TIMEOUT = 30000;
+
+ private static final String USERNAME_PREFIX = "Username:"; //$NON-NLS-1$
+
+ private JREProxyHelper proxyHelper = null;
+
+ protected String username = null;
+
+ protected String password = null;
+
+ protected HttpClient httpClient = null;
+
+ protected GetMethod getMethod;
+
+ /**
+ * @param directoryOrFileID
+ * @param listener
+ */
+ public HttpClientFileSystemBrowser(HttpClient httpClient, IFileID directoryOrFileID, IRemoteFileSystemListener listener, URL directoryOrFileURL, IConnectContext connectContext, Proxy proxy) {
+ super(directoryOrFileID, listener, directoryOrFileURL, connectContext, proxy);
+ Assert.isNotNull(httpClient);
+ this.httpClient = httpClient;
+ proxyHelper = new JREProxyHelper();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.provider.filetransfer.browse.AbstractFileSystemBrowser#runRequest()
+ */
+ protected void runRequest() throws Exception {
+ Trace.entering(Activator.PLUGIN_ID, DebugOptions.METHODS_ENTERING, this.getClass(), "runRequest"); //$NON-NLS-1$
+ setupProxies();
+ // set timeout
+ httpClient.getHttpConnectionManager().getParams().setSoTimeout(DEFAULT_CONNECTION_TIMEOUT);
+ httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT);
+ String urlString = directoryOrFile.toString();
+ // setup authentication
+ setupAuthentication(urlString);
+ // setup https host and port
+ setupHostAndPort(urlString);
+
+ getMethod = new GetMethod(urlString);
+ getMethod.setFollowRedirects(true);
+ // Define a CredentialsProvider - found that possibility while debugging in org.apache.commons.httpclient.HttpMethodDirector.processProxyAuthChallenge(HttpMethod)
+ // Seems to be another way to select the credentials.
+ getMethod.getParams().setParameter(CredentialsProvider.PROVIDER, new ECFCredentialsProvider());
+ // set max-age for cache control to 0 for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=249990
+ getMethod.addRequestHeader("Cache-Control", "max-age=0"); //$NON-NLS-1$//$NON-NLS-2$
+
+ long lastModified = 0;
+ long fileLength = -1;
+ try {
+ Trace.trace(Activator.PLUGIN_ID, "browse=" + urlString); //$NON-NLS-1$
+
+ int code = httpClient.executeMethod(getMethod);
+
+ Trace.trace(Activator.PLUGIN_ID, "browse resp=" + code); //$NON-NLS-1$
+
+ if (code == HttpURLConnection.HTTP_OK) {
+ fileLength = getMethod.getResponseContentLength();
+ lastModified = getLastModifiedTimeFromHeader();
+ } else if (code == HttpURLConnection.HTTP_NOT_FOUND) {
+ throw new FileNotFoundException(urlString);
+ } else if (code == HttpURLConnection.HTTP_UNAUTHORIZED) {
+ throw new LoginException(Messages.HttpClientRetrieveFileTransfer_Unauthorized);
+ } else if (code == HttpURLConnection.HTTP_FORBIDDEN) {
+ throw new LoginException("Forbidden"); //$NON-NLS-1$
+ } else if (code == HttpURLConnection.HTTP_PROXY_AUTH) {
+ throw new LoginException(Messages.HttpClientRetrieveFileTransfer_Proxy_Auth_Required);
+ } else {
+ throw new IOException(NLS.bind(Messages.HttpClientRetrieveFileTransfer_ERROR_GENERAL_RESPONSE_CODE, new Integer(code)));
+ }
+ remoteFiles = new IRemoteFile[1];
+ remoteFiles[0] = new URLRemoteFile(lastModified, fileLength, fileID);
+ } catch (Exception e) {
+ Trace.throwing(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_THROWING, this.getClass(), "runRequest", e); //$NON-NLS-1$
+ throw e;
+ } finally {
+ getMethod.releaseConnection();
+ }
+ }
+
+ private long getLastModifiedTimeFromHeader() throws IOException {
+ Header lastModifiedHeader = getMethod.getResponseHeader("Last-Modified"); //$NON-NLS-1$
+ if (lastModifiedHeader == null)
+ return 0L;
+ String lastModifiedString = lastModifiedHeader.getValue();
+ long lastModified = 0;
+ if (lastModifiedString != null) {
+ try {
+ lastModified = DateUtil.parseDate(lastModifiedString).getTime();
+ } catch (Exception e) {
+ throw new IOException(Messages.HttpClientRetrieveFileTransfer_EXCEPITION_INVALID_LAST_MODIFIED_FROM_SERVER);
+ }
+ }
+ return lastModified;
+ }
+
+ final class ECFCredentialsProvider implements CredentialsProvider {
+
+ /**
+ * @throws CredentialsNotAvailableException
+ */
+ public Credentials getCredentials(AuthScheme scheme, String host, int port, boolean isProxyAuthenticating) throws CredentialsNotAvailableException {
+ if ("ntlm".equalsIgnoreCase(scheme.getSchemeName())) { //$NON-NLS-1$
+ return HttpClientRetrieveFileTransfer.createNTLMCredentials(getProxy());
+ }
+ return null;
+ }
+ }
+
+ Proxy getProxy() {
+ return proxy;
+ }
+
+ protected void setupHostAndPort(String urlString) {
+ String host = HttpClientRetrieveFileTransfer.getHostFromURL(urlString);
+ int port = HttpClientRetrieveFileTransfer.getPortFromURL(urlString);
+ if (HttpClientRetrieveFileTransfer.urlUsesHttps(urlString)) {
+ ISSLSocketFactoryModifier sslSocketFactoryModifier = Activator.getDefault().getSSLSocketFactoryModifier();
+ Protocol sslProtocol = null;
+ ProtocolSocketFactory psf = null;
+ if (sslSocketFactoryModifier != null) {
+ psf = sslSocketFactoryModifier.getProtocolSocketFactoryForProxy(proxy);
+ } else {
+ psf = new HttpClientSslProtocolSocketFactory(proxy);
+ }
+ sslProtocol = new Protocol(HttpClientRetrieveFileTransfer.HTTPS, psf, port);
+ Protocol.registerProtocol(HttpClientRetrieveFileTransfer.HTTPS, sslProtocol);
+ Trace.trace(Activator.PLUGIN_ID, "browse host=" + host + ";port=" + port); //$NON-NLS-1$ //$NON-NLS-2$
+ httpClient.getHostConfiguration().setHost(host, port, sslProtocol);
+ } else {
+ Trace.trace(Activator.PLUGIN_ID, "browse host=" + host + ";port=" + port); //$NON-NLS-1$ //$NON-NLS-2$
+ httpClient.getHostConfiguration().setHost(host, port);
+ }
+ }
+
+ protected Credentials getFileRequestCredentials() throws UnsupportedCallbackException, IOException {
+ if (connectContext == null)
+ return null;
+ final CallbackHandler callbackHandler = connectContext.getCallbackHandler();
+ if (callbackHandler == null)
+ return null;
+ final NameCallback usernameCallback = new NameCallback(USERNAME_PREFIX);
+ final ObjectCallback passwordCallback = new ObjectCallback();
+ callbackHandler.handle(new Callback[] {usernameCallback, passwordCallback});
+ username = usernameCallback.getName();
+ password = (String) passwordCallback.getObject();
+ return new UsernamePasswordCredentials(username, password);
+ }
+
+ protected void setupAuthentication(String urlString) throws UnsupportedCallbackException, IOException {
+ Credentials credentials = null;
+ if (username == null) {
+ credentials = getFileRequestCredentials();
+ }
+
+ if (credentials != null && username != null) {
+ final AuthScope authScope = new AuthScope(HttpClientRetrieveFileTransfer.getHostFromURL(urlString), HttpClientRetrieveFileTransfer.getPortFromURL(urlString), AuthScope.ANY_REALM);
+ Trace.trace(Activator.PLUGIN_ID, "browse credentials=" + credentials); //$NON-NLS-1$
+ httpClient.getState().setCredentials(authScope, credentials);
+ }
+ }
+
+ protected void setupProxy(Proxy proxy) {
+ if (proxy.getType().equals(Proxy.Type.HTTP)) {
+ final ProxyAddress address = proxy.getAddress();
+ httpClient.getHostConfiguration().setProxy(HttpClientRetrieveFileTransfer.getHostFromURL(address.getHostName()), address.getPort());
+ final String proxyUsername = proxy.getUsername();
+ final String proxyPassword = proxy.getPassword();
+ if (proxyUsername != null) {
+ final Credentials credentials = new UsernamePasswordCredentials(proxyUsername, proxyPassword);
+ final AuthScope proxyAuthScope = new AuthScope(address.getHostName(), address.getPort(), AuthScope.ANY_REALM);
+ Trace.trace(Activator.PLUGIN_ID, "browse httpproxy=" + proxyAuthScope + ";credentials" + credentials); //$NON-NLS-1$ //$NON-NLS-2$
+ httpClient.getState().setProxyCredentials(proxyAuthScope, credentials);
+ }
+ } else if (proxy.getType().equals(Proxy.Type.SOCKS)) {
+ Trace.trace(Activator.PLUGIN_ID, "brows socksproxy=" + proxy.getAddress()); //$NON-NLS-1$
+ proxyHelper.setupProxy(proxy);
+ }
+ }
+
+}
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java
index f2b77dc30..8b6db9702 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java
@@ -22,8 +22,7 @@ import org.apache.commons.httpclient.util.DateUtil;
import org.eclipse.core.runtime.*;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.security.*;
-import org.eclipse.ecf.core.util.Proxy;
-import org.eclipse.ecf.core.util.ProxyAddress;
+import org.eclipse.ecf.core.util.*;
import org.eclipse.ecf.filetransfer.*;
import org.eclipse.ecf.filetransfer.identity.IFileID;
import org.eclipse.ecf.internal.provider.filetransfer.httpclient.*;
@@ -75,6 +74,7 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
InputStream input = super.getResponseBodyAsStream();
try {
if (gzipReceived) {
+ Trace.trace(Activator.PLUGIN_ID, "retrieve content-encoding: gzip"); //$NON-NLS-1$
// extract on the fly
return new java.util.zip.GZIPInputStream(input);
}
@@ -176,11 +176,14 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
if (credentials != null && username != null) {
final AuthScope authScope = new AuthScope(getHostFromURL(urlString), getPortFromURL(urlString), AuthScope.ANY_REALM);
+ Trace.trace(Activator.PLUGIN_ID, "retrieve credentials=" + credentials); //$NON-NLS-1$
httpClient.getState().setCredentials(authScope, credentials);
}
}
protected void setupHostAndPort(String urlString) {
+ String host = getHostFromURL(urlString);
+ int port = getPortFromURL(urlString);
if (urlUsesHttps(urlString)) {
ISSLSocketFactoryModifier sslSocketFactoryModifier = Activator.getDefault().getSSLSocketFactoryModifier();
Protocol sslProtocol = null;
@@ -190,11 +193,13 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
} else {
psf = new HttpClientSslProtocolSocketFactory(proxy);
}
- sslProtocol = new Protocol(HTTPS, psf, getPortFromURL(urlString));
+ sslProtocol = new Protocol(HTTPS, psf, port);
Protocol.registerProtocol(HTTPS, sslProtocol);
- httpClient.getHostConfiguration().setHost(getHostFromURL(urlString), getPortFromURL(urlString), sslProtocol);
+ Trace.trace(Activator.PLUGIN_ID, "retrieve host=" + host + ";port=" + port); //$NON-NLS-1$ //$NON-NLS-2$
+ httpClient.getHostConfiguration().setHost(host, port, sslProtocol);
} else {
- httpClient.getHostConfiguration().setHost(getHostFromURL(urlString), getPortFromURL(urlString));
+ Trace.trace(Activator.PLUGIN_ID, "retrieve host=" + host + ";port=" + port); //$NON-NLS-1$ //$NON-NLS-2$
+ httpClient.getHostConfiguration().setHost(host, port);
}
}
@@ -207,7 +212,9 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
throw new InvalidFileRangeSpecificationException(Messages.HttpClientRetrieveFileTransfer_RESUME_START_POSITION_LESS_THAN_ZERO, rangeSpec);
if (endPosition != -1L && endPosition <= startPosition)
throw new InvalidFileRangeSpecificationException(Messages.HttpClientRetrieveFileTransfer_RESUME_ERROR_END_POSITION_LESS_THAN_START, rangeSpec);
- setRangeHeader("bytes=" + startPosition + "-" + ((endPosition == -1L) ? "" : ("" + endPosition))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ String rangeHeader = "bytes=" + startPosition + "-" + ((endPosition == -1L) ? "" : ("" + endPosition)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Trace.trace(Activator.PLUGIN_ID, "retrieve range header=" + rangeHeader); //$NON-NLS-1$
+ setRangeHeader(rangeHeader);
}
// set max-age for cache control to 0 for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=249990
getMethod.addRequestHeader("Cache-Control", "max-age=0"); //$NON-NLS-1$//$NON-NLS-2$
@@ -314,6 +321,8 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
* @see org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer#openStreams()
*/
protected void openStreams() throws IncomingFileTransferException {
+
+ Trace.entering(Activator.PLUGIN_ID, DebugOptions.METHODS_ENTERING, this.getClass(), "openStreams"); //$NON-NLS-1$
final String urlString = getRemoteFileURL().toString();
int code = -1;
@@ -333,8 +342,12 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
getMethod.getParams().setParameter(CredentialsProvider.PROVIDER, new ECFCredentialsProvider());
setRequestHeaderValues();
+ Trace.trace(Activator.PLUGIN_ID, "retrieve=" + urlString); //$NON-NLS-1$
+
code = httpClient.executeMethod(getMethod);
+ Trace.trace(Activator.PLUGIN_ID, "retrieve resp=" + code); //$NON-NLS-1$
+
if (code == HttpURLConnection.HTTP_PARTIAL || code == HttpURLConnection.HTTP_OK) {
getResponseHeaderValues();
setInputStream(getMethod.getResponseBodyAsUnzippedStream());
@@ -356,9 +369,11 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
throw new IOException(NLS.bind(Messages.HttpClientRetrieveFileTransfer_ERROR_GENERAL_RESPONSE_CODE, new Integer(code)));
}
} catch (final Exception e) {
- throw new IncomingFileTransferException(NLS.bind(Messages.HttpClientRetrieveFileTransfer_EXCEPTION_COULD_NOT_CONNECT, urlString), e, code);
+ IncomingFileTransferException ex = new IncomingFileTransferException(NLS.bind(Messages.HttpClientRetrieveFileTransfer_EXCEPTION_COULD_NOT_CONNECT, urlString), e, code);
+ Trace.throwing(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_THROWING, this.getClass(), "openStreams", ex); //$NON-NLS-1$
+ throw ex;
}
-
+ Trace.exiting(Activator.PLUGIN_ID, DebugOptions.METHODS_EXITING, this.getClass(), "openStreams"); //$NON-NLS-1$
}
/*
@@ -467,6 +482,7 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
}
private boolean openStreamsForResume() {
+ Trace.entering(Activator.PLUGIN_ID, DebugOptions.METHODS_ENTERING, this.getClass(), "openStreamsForResume"); //$NON-NLS-1$
final URL theURL = getRemoteFileURL();
int code = -1;
@@ -487,8 +503,12 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
setResumeRequestHeaderValues();
+ Trace.trace(Activator.PLUGIN_ID, "resume get " + urlString); //$NON-NLS-1$
+
code = httpClient.executeMethod(getMethod);
+ Trace.trace(Activator.PLUGIN_ID, "resume get resp=" + code); //$NON-NLS-1$
+
if (code == HttpURLConnection.HTTP_PARTIAL || code == HttpURLConnection.HTTP_OK) {
getResumeResponseHeaderValues();
setInputStream(getMethod.getResponseBodyAsUnzippedStream());
@@ -508,12 +528,15 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
getMethod.releaseConnection();
throw new IOException(NLS.bind(Messages.HttpClientRetrieveFileTransfer_ERROR_GENERAL_RESPONSE_CODE, new Integer(code)));
}
+ Trace.exiting(Activator.PLUGIN_ID, DebugOptions.METHODS_EXITING, this.getClass(), "openStreamsForResume", Boolean.TRUE); //$NON-NLS-1$
return true;
} catch (final Exception e) {
this.exception = e;
this.done = true;
+ Trace.catching(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_THROWING, this.getClass(), "openStreamsForResume", e); //$NON-NLS-1$
hardClose();
fireTransferReceiveDoneEvent();
+ Trace.exiting(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_THROWING, this.getClass(), "openStreamsForResume", Boolean.FALSE); //$NON-NLS-1$
return false;
}
}
@@ -550,14 +573,16 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
if (proxyUsername != null) {
final Credentials credentials = new UsernamePasswordCredentials(proxyUsername, proxyPassword);
final AuthScope proxyAuthScope = new AuthScope(address.getHostName(), address.getPort(), AuthScope.ANY_REALM);
+ Trace.trace(Activator.PLUGIN_ID, "retrieve httpproxy=" + proxyAuthScope + ";credentials" + credentials); //$NON-NLS-1$ //$NON-NLS-2$
httpClient.getState().setProxyCredentials(proxyAuthScope, credentials);
}
} else if (proxy.getType().equals(Proxy.Type.SOCKS)) {
+ Trace.trace(Activator.PLUGIN_ID, "retrieve socksproxy=" + proxy.getAddress()); //$NON-NLS-1$
proxyHelper.setupProxy(proxy);
}
}
- protected NTCredentials createNTLMCredentials(Proxy p) {
+ protected static NTCredentials createNTLMCredentials(Proxy p) {
if (p == null) {
return null;
}
@@ -568,7 +593,7 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
return new NTCredentials(un, p.getPassword(), p.getAddress().getHostName(), domain);
}
- protected String getNTLMDomainName(Proxy p) {
+ protected static String getNTLMDomainName(Proxy p) {
String domainUsername = p.getUsername();
int slashloc = domainUsername.indexOf('\\');
if (slashloc == -1)
@@ -576,7 +601,7 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
return domainUsername.substring(0, slashloc);
}
- protected String getNTLMUserName(Proxy p) {
+ protected static String getNTLMUserName(Proxy p) {
String domainUsername = p.getUsername();
int slashloc = domainUsername.indexOf('\\');
if (slashloc == -1)
@@ -584,4 +609,29 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
return domainUsername.substring(slashloc + 1);
}
+ protected void fireReceiveStartEvent() {
+ Trace.entering(Activator.PLUGIN_ID, DebugOptions.METHODS_ENTERING, this.getClass(), "fireReceiveStartEvent len=" + fileLength + ";rcvd=" + bytesReceived); //$NON-NLS-1$ //$NON-NLS-2$
+ super.fireReceiveStartEvent();
+ }
+
+ protected void fireReceiveResumedEvent() {
+ Trace.entering(Activator.PLUGIN_ID, DebugOptions.METHODS_ENTERING, this.getClass(), "fireReceiveResumedEvent len=" + fileLength + ";rcvd=" + bytesReceived); //$NON-NLS-1$ //$NON-NLS-2$
+ super.fireReceiveResumedEvent();
+ }
+
+ protected void fireTransferReceiveDataEvent() {
+ Trace.entering(Activator.PLUGIN_ID, DebugOptions.METHODS_ENTERING, this.getClass(), "fireTransferReceiveDataEvent len=" + fileLength + ";rcvd=" + bytesReceived); //$NON-NLS-1$ //$NON-NLS-2$
+ super.fireTransferReceiveDataEvent();
+ }
+
+ protected void fireTransferReceiveDoneEvent() {
+ Trace.entering(Activator.PLUGIN_ID, DebugOptions.METHODS_ENTERING, this.getClass(), "fireTransferReceiveDoneEvent len=" + fileLength + ";rcvd=" + bytesReceived); //$NON-NLS-1$ //$NON-NLS-2$
+ super.fireTransferReceiveDoneEvent();
+ }
+
+ protected void fireTransferReceivePausedEvent() {
+ Trace.entering(Activator.PLUGIN_ID, DebugOptions.METHODS_ENTERING, this.getClass(), "fireTransferReceivePausedEvent len=" + fileLength + ";rcvd=" + bytesReceived); //$NON-NLS-1$ //$NON-NLS-2$
+ super.fireTransferReceivePausedEvent();
+ }
+
}

Back to the top