diff options
author | Pascal Rapicault | 2016-06-06 00:59:06 +0000 |
---|---|---|
committer | Pascal Rapicault | 2016-06-06 00:59:06 +0000 |
commit | e421fd9ec19155d412a64851f348e23dbbd3a948 (patch) | |
tree | d8f2966c3e52b4b7a60a1faa658b62e64f81c54c | |
parent | 3bcec796ae83cd5400228185662275446056993f (diff) | |
download | rt.equinox.p2-e421fd9ec19155d412a64851f348e23dbbd3a948.tar.gz rt.equinox.p2-e421fd9ec19155d412a64851f348e23dbbd3a948.tar.xz rt.equinox.p2-e421fd9ec19155d412a64851f348e23dbbd3a948.zip |
Revert "Bug 490112 - Add unique id to p2 user agent information"
This reverts commit 3bcec796ae83cd5400228185662275446056993f.
Change-Id: If8e8ecf95f28a1143fcbeacd7f4947f397eaabec
-rw-r--r-- | bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/FileReader.java | 52 |
1 files changed, 15 insertions, 37 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 c3f45b0f6..09d8dc46c 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 @@ -1,14 +1,13 @@ - /******************************************************************************* - * Copyright (c) 2006, 2016 Cloudsmith Inc. + * Copyright (c) 2006, 2015 Cloudsmith Inc. * 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: - * Cloudsmith Inc - initial API and implementation - * IBM Corporation - ongoing development + * Cloudsmith Inc - initial API and implementation + * IBM Corporation - ongoing development * Sonatype Inc - ongoing development * Ericsson AB. - Bug 407940 - [transport] Initial connection happens in current thread * Red Hat Inc. - Bug 460967 @@ -56,8 +55,7 @@ public final class FileReader extends FileTransferJob implements IFileTransferLi } } - static Map<String, Map<String, String>> userAgentWithoutUUIDOptions; - static Map<String, Map<String, String>> userAgentOptions; + static Map<String, Map<String, String>> options; static private String getProperty(String key, String defaultValue) { String value = Activator.getContext().getProperty(key); @@ -68,6 +66,7 @@ public final class FileReader extends FileTransferJob implements IFileTransferLi } static { + Map<String, String> extraRequestHeaders = new HashMap<String, String>(1); 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$ @@ -77,34 +76,18 @@ public final class FileReader extends FileTransferJob implements IFileTransferLi String osVersion = getProperty("org.osgi.framework.os.version", "unknownOSVersion"); //$NON-NLS-1$ //$NON-NLS-2$ String uuid = getProperty("eclipse.uuid", "unknownUUID"); //$NON-NLS-1$//$NON-NLS-2$ userAgent = "p2/neon-sr0 (Java " + javaSpec + ' ' + javaVendor + "; " + osName + ' ' + osVersion + ' ' + osgiArch + "; " + language + "; " + uuid + ") "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - String userAgentNoUUID = "p2/neon-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$ - String suffix = productId + '/' + buildId + " (" + appId + ')'; //$NON-NLS-1$ - userAgent += suffix; - userAgentNoUUID += suffix; + userAgent += productId + '/' + buildId + " (" + appId + ')'; //$NON-NLS-1$ } else { userAgent += userAgentProvided; - userAgentNoUUID += userAgentProvided; - } - - { - //Create an option map that includes the user agent with uuid (used when we are contacting eclipse.org servers) - Map<String, String> extraRequestHeaders = new HashMap<String, String>(1); - extraRequestHeaders.put("User-Agent", userAgent); //$NON-NLS-1$ - userAgentOptions = new HashMap<String, Map<String, String>>(1); - userAgentOptions.put(org.eclipse.ecf.filetransfer.IRetrieveFileTransferOptions.REQUEST_HEADERS, extraRequestHeaders); - } - { - //Create an option map that includes the user agent without uuid - Map<String, String> extraRequestHeaders = new HashMap<String, String>(1); - extraRequestHeaders.put("User-Agent", userAgentNoUUID); //$NON-NLS-1$ - userAgentWithoutUUIDOptions = new HashMap<String, Map<String, String>>(1); - userAgentWithoutUUIDOptions.put(org.eclipse.ecf.filetransfer.IRetrieveFileTransferOptions.REQUEST_HEADERS, extraRequestHeaders); } + 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; @@ -438,15 +421,10 @@ public final class FileReader extends FileTransferJob implements IFileTransferLi try { IFileID fileID = FileIDFactory.getDefault().createFileID(adapter.getRetrieveNamespace(), uri.toString()); - Map<String, Map<String, String>> options = userAgentWithoutUUIDOptions; - if (uri.getHost() != null && uri.getHost().endsWith(".eclipse.org")) //$NON-NLS-1$ - options = userAgentOptions; - - if (range != null) { + if (range != null) adapter.sendRetrieveRequest(fileID, range, this, options); - } else { + else adapter.sendRetrieveRequest(fileID, this, options); - } } catch (IncomingFileTransferException e) { exception = e; } catch (FileCreateException e) { @@ -480,7 +458,7 @@ public final class FileReader extends FileTransferJob implements IFileTransferLi /** * Utility method to check exception condition and determine if retry should be done. * If there was an exception it is translated into one of the specified exceptions and thrown. - * + * * @param uri the URI being read - used for logging purposes * @param attemptCounter - the current attempt number (start with 0) * @return true if the exception is an IOException and attemptCounter < connectionRetryCount, false otherwise @@ -594,7 +572,7 @@ public final class FileReader extends FileTransferJob implements IFileTransferLi * Sets the progress statistics. This method is synchronized because the field * is accessed from both the transfer thread and the thread initiating the transfer * and we need to ensure field values are consistent across threads. - * + * * @param statistics the statistics to set, or <code>null</code> */ private synchronized void setStatistics(ProgressStatistics statistics) { @@ -605,7 +583,7 @@ public final class FileReader extends FileTransferJob implements IFileTransferLi * Returns the progress statistics. This method is synchronized because the field * is accessed from both the transfer thread and the thread initiating the transfer * and we need to ensure field values are consistent across threads. - * + * * @return the statistics, or <code>null</code> */ private synchronized ProgressStatistics getStatistics() { |