/** * Sets the user agent to {@code "<name>/<release> (Java 1.5 minimum; Java/<java.version>)"}. * <p/> * For example: * <pre>"Apache-HttpClient/4.3 (Java 1.5 minimum; Java/1.6.0_35)"</pre> * * @param name the component name, like "Apache-HttpClient". * @param pkg * the package for which to load version information, for example "org.apache.http". The package name * should NOT end with a dot. * @param cls * the class' class loader to load from, or <code>null</code> for the thread context class loader * @since 4.3 */ public static String getUserAgent(final String name, final String pkg, final Class<?> cls) { // determine the release version from packaged version info final VersionInfoHC4 vi = VersionInfoHC4.loadVersionInfo(pkg, cls.getClassLoader()); final String release = (vi != null) ? vi.getRelease() : VersionInfoHC4.UNAVAILABLE; final String javaVersion = System.getProperty("java.version"); return name + "/" + release + " (Java 1.5 minimum; Java/" + javaVersion + ")"; }
/** * Loads version information for a list of packages. * * @param pckgs the packages for which to load version info * @param clsldr the classloader to load from, or * <code>null</code> for the thread context classloader * * @return the version information for all packages found, * never <code>null</code> */ public static VersionInfo[] loadVersionInfo(final String[] pckgs, final ClassLoader clsldr) { Args.notNull(pckgs, "Package identifier array"); final List<VersionInfoHC4> vil = new ArrayList<VersionInfoHC4>(pckgs.length); for (final String pckg : pckgs) { final VersionInfoHC4 vi = loadVersionInfo(pckg, clsldr); if (vi != null) { vil.add(vi); } } return vil.toArray(new VersionInfo[vil.size()]); }
result = fromMap(pckg, vip, cl);
return new VersionInfoHC4(pckg, module, release, timestamp, clsldrstr);
public MinimalClientExec( final HttpRequestExecutor requestExecutor, final HttpClientConnectionManager connManager, final ConnectionReuseStrategy reuseStrategy, final ConnectionKeepAliveStrategy keepAliveStrategy) { Args.notNull(requestExecutor, "HTTP request executor"); Args.notNull(connManager, "Client connection manager"); Args.notNull(reuseStrategy, "Connection reuse strategy"); Args.notNull(keepAliveStrategy, "Connection keep alive strategy"); this.httpProcessor = new ImmutableHttpProcessor( new RequestContentHC4(), new RequestTargetHostHC4(), new RequestClientConnControl(), new RequestUserAgentHC4(VersionInfoHC4.getUserAgent( "Apache-HttpClient", "org.apache.http.client", getClass()))); this.requestExecutor = requestExecutor; this.connManager = connManager; this.reuseStrategy = reuseStrategy; this.keepAliveStrategy = keepAliveStrategy; }