Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2015-05-20 19:22:23 -0400
committerPascal Rapicault2015-05-21 09:42:46 -0400
commit4c9d46150f2487b71ed0bacf9e0e178c33b6912e (patch)
tree84fa3da028a3f997ea0d6fcc5b917427799c1391
parentb8af4c44ea1e784a9b07a3842f9aa1c775670264 (diff)
downloadrt.equinox.p2-4c9d46150f2487b71ed0bacf9e0e178c33b6912e.tar.gz
rt.equinox.p2-4c9d46150f2487b71ed0bacf9e0e178c33b6912e.tar.xz
rt.equinox.p2-4c9d46150f2487b71ed0bacf9e0e178c33b6912e.zip
Bug 467447 - Set more specific user agentI20150521-1715I20150521-1400I20150521-1100
Change-Id: If7be4c0a106d09f7af069a4ed2bab105dfe403cb Signed-off-by: Pascal Rapicault <pascal@rapicorp.com>
-rw-r--r--bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/FileReader.java32
1 files changed, 24 insertions, 8 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 52b621d13..701e0330a 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
@@ -57,16 +57,32 @@ public final class FileReader extends FileTransferJob implements IFileTransferLi
static Map<String, Map<String, String>> options;
+ static private String getProperty(String key, String defaultValue) {
+ String value = Activator.getContext().getProperty(key);
+ if (value == null) {
+ value = defaultValue;
+ }
+ return value;
+ }
+
static {
Map<String, String> extraRequestHeaders = new HashMap<String, String>(1);
- String userAgent = System.getProperty("p2.userAgent"); //$NON-NLS-1$
- if (userAgent == null) {
- String productId = System.getProperty("eclipse.product", "eclipse"); //$NON-NLS-1$ //$NON-NLS-2$
- String appId = System.getProperty("eclipse.application", "noApp"); //$NON-NLS-1$ //$NON-NLS-2$
- String javaSpec = System.getProperty("java.runtime.version", "unknownJava"); //$NON-NLS-1$//$NON-NLS-2$
- String osName = System.getProperty("org.osgi.framework.os.name", "unknownOS"); //$NON-NLS-1$ //$NON-NLS-2$
- String osVersion = System.getProperty("org.osgi.framework.os.version", "unknownOSVersion"); //$NON-NLS-1$ //$NON-NLS-2$
- userAgent = productId + "/mars (" + appId + "; Java " + javaSpec + "; " + osName + ' ' + osVersion + ')'; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ String userAgent = null;
+ String javaSpec = getProperty("java.runtime.version", "unknownJava"); //$NON-NLS-1$//$NON-NLS-2$
+ String javaVendor = getProperty("java.vendor", "unknownJavaVendor");//$NON-NLS-1$//$NON-NLS-2$
+ String osName = getProperty("org.osgi.framework.os.name", "unknownOS"); //$NON-NLS-1$ //$NON-NLS-2$
+ String osgiArch = getProperty("org.osgi.framework.processor", "unknownArch");//$NON-NLS-1$//$NON-NLS-2$
+ String language = getProperty("osgi.nl", "unknownLanguage");//$NON-NLS-1$//$NON-NLS-2$
+ String osVersion = getProperty("org.osgi.framework.os.version", "unknownOSVersion"); //$NON-NLS-1$ //$NON-NLS-2$
+ userAgent = "p2/mars-sr0 (Java " + javaSpec + ' ' + javaVendor + "; " + osName + ' ' + osVersion + ' ' + osgiArch + "; " + language + ") "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ String userAgentProvided = getProperty("p2.userAgent", null); //$NON-NLS-1$
+ if (userAgentProvided == null) {
+ String productId = getProperty("eclipse.product", "unknownProduct"); //$NON-NLS-1$ //$NON-NLS-2$
+ String appId = getProperty("eclipse.application", "unknownApp"); //$NON-NLS-1$ //$NON-NLS-2$
+ String buildId = getProperty("eclipse.buildId", "unknownBuildId"); //$NON-NLS-1$ //$NON-NLS-2$
+ userAgent += productId + '/' + buildId + " (" + appId + ')'; //$NON-NLS-1$
+ } else {
+ userAgent += userAgentProvided;
}
extraRequestHeaders.put("User-Agent", userAgent); //$NON-NLS-1$
options = new HashMap<String, Map<String, String>>(1);

Back to the top