Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2015-05-14 21:49:54 +0000
committerPascal Rapicault2015-05-15 16:10:16 +0000
commitdc523545d91da191ccdf7ffbf39d059172549e26 (patch)
treeb6daf167fb64a5b09a8941f73a9db422c1f80f85
parent6f41814a6470902af431cd2ff10ac67ae3c00550 (diff)
downloadrt.equinox.p2-dc523545d91da191ccdf7ffbf39d059172549e26.tar.gz
rt.equinox.p2-dc523545d91da191ccdf7ffbf39d059172549e26.tar.xz
rt.equinox.p2-dc523545d91da191ccdf7ffbf39d059172549e26.zip
Bug 467286 - Set the ECF user agent property
-rw-r--r--bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/FileReader.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/FileReader.java b/bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/FileReader.java
index dd339a06f..8f07e99d2 100644
--- a/bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/FileReader.java
+++ b/bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/FileReader.java
@@ -11,13 +11,14 @@
* Sonatype Inc - ongoing development
* Ericsson AB. - Bug 407940 - [transport] Initial connection happens in current thread
* Red Hat Inc. - Bug 460967
+ * Rapicorp Inc - Bug 467286 - Set the ECF user agent property
******************************************************************************/
package org.eclipse.equinox.internal.p2.transport.ecf;
import java.io.*;
import java.net.SocketTimeoutException;
import java.net.URI;
-import java.util.Date;
+import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.ecf.core.security.IConnectContext;
@@ -54,6 +55,18 @@ public final class FileReader extends FileTransferJob implements IFileTransferLi
}
}
+ static Map<String, Map<String, String>> options;
+
+ static {
+ Map<String, String> extraRequestHeaders = new HashMap<String, String>(1);
+ String userAgent = System.getProperty("p2.userAgent"); //$NON-NLS-1$
+ if (userAgent == null)
+ userAgent = "eclipse/p2/mars"; //$NON-NLS-1$
+ extraRequestHeaders.put("User-Agent", userAgent); //$NON-NLS-1$
+ options = new HashMap<String, Map<String, String>>(1);
+ options.put(org.eclipse.ecf.filetransfer.IRetrieveFileTransferOptions.REQUEST_HEADERS, extraRequestHeaders);
+ }
+
private static IFileReaderProbe testProbe;
private boolean closeStreamWhenFinished = false;
private Exception exception;
@@ -384,10 +397,11 @@ public final class FileReader extends FileTransferJob implements IFileTransferLi
try {
IFileID fileID = FileIDFactory.getDefault().createFileID(adapter.getRetrieveNamespace(), uri.toString());
+
if (range != null)
- adapter.sendRetrieveRequest(fileID, range, this, null);
+ adapter.sendRetrieveRequest(fileID, range, this, options);
else
- adapter.sendRetrieveRequest(fileID, this, null);
+ adapter.sendRetrieveRequest(fileID, this, options);
} catch (IncomingFileTransferException e) {
exception = e;
} catch (FileCreateException e) {

Back to the top