@Override protected HttpParams createHttpParams() { HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET); /* * Android note: Send each request body without first asking the server * whether it will be accepted. Asking first slows down the common case * and results in "417 expectation failed" errors when a HTTP/1.0 server * is behind a proxy. http://b/2471595 */ HttpProtocolParams.setUseExpectContinue(params, false); // android-changed // determine the release version from packaged version info final VersionInfo vi = VersionInfo.loadVersionInfo ("org.apache.http.client", getClass().getClassLoader()); final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE; HttpProtocolParams.setUserAgent(params, "Apache-HttpClient/" + release + " (java 1.4)"); return params; }
private String getVersionInfo() { // determine the release version from packaged version info final VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.client", getClass().getClassLoader()); return (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE; }
VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.client",getClass().getClassLoader()); String version = vi.getRelease(); Log.d("apache http client version", version);
/** * Sets the user agent to {@code "<name>/<release> (Java/<java.version>)"}. * <p> * For example: * <pre>"Apache-HttpClient/4.3 (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} 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 VersionInfo vi = VersionInfo.loadVersionInfo(pkg, cls.getClassLoader()); final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE; final String javaVersion = System.getProperty("java.version"); return String.format("%s/%s (Java/%s)", name, release, javaVersion); }
/** * Sets the user agent to {@code "<name>/<release> (Java/<java.version>)"}. * <p> * For example: * <pre>"Apache-HttpClient/4.3 (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} 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 VersionInfo vi = VersionInfo.loadVersionInfo(pkg, cls.getClassLoader()); final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE; final String javaVersion = System.getProperty("java.version"); return String.format("%s/%s (Java/%s)", name, release, javaVersion); }
/** * 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 VersionInfo vi = VersionInfo.loadVersionInfo(pkg, cls.getClassLoader()); final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE; final String javaVersion = System.getProperty("java.version"); return name + "/" + release + " (Java 1.5 minimum; Java/" + javaVersion + ")"; }
/** * Sets the user agent to {@code "<name>/<release> (Java/<java.version>)"}. * <p> * For example: * <pre>"Apache-HttpClient/4.3 (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} 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 VersionInfo vi = VersionInfo.loadVersionInfo(pkg, cls.getClassLoader()); final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE; final String javaVersion = System.getProperty("java.version"); return String.format("%s/%s (Java/%s)", name, release, javaVersion); }
/** * Sets the user agent to {@code "<name>/<release> (Java/<java.version>)"}. * <p> * For example: * <pre>"Apache-HttpClient/4.3 (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} 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 VersionInfo vi = VersionInfo.loadVersionInfo(pkg, cls.getClassLoader()); final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE; final String javaVersion = System.getProperty("java.version"); return String.format("%s/%s (Java/%s)", name, release, javaVersion); }
/** * Get the appropriate fallback domain depending on the current SNI support. * Checks Java version and Apache HTTP Client's version. * * @return algolianet.com if the current setup supports SNI, else algolia.net. */ static String getFallbackDomain() { int javaVersion = getJavaVersion(); boolean javaHasSNI = javaVersion >= 7; final VersionInfo vi = VersionInfo.loadVersionInfo ("org.apache.http.client", APIClient.class.getClassLoader()); String version = vi.getRelease(); String[] split = version.split("\\."); int major = Integer.parseInt(split[0]); int minor = Integer.parseInt(split[1]); int patch = Integer.parseInt(split[2]); boolean apacheClientHasSNI = major > 4 || major == 4 && minor > 3 || major == 4 && minor == 3 && patch >= 2; // if version >= 4.3.2 if (apacheClientHasSNI && javaHasSNI) { return "algolianet.com"; } else { return "algolia.net"; } }
private String generateViaHeader(HttpMessage msg) { final ProtocolVersion pv = msg.getProtocolVersion(); String existingEntry = viaHeaders.get(pv); if (existingEntry != null) return existingEntry; final VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.client", getClass().getClassLoader()); final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE; String value; if ("http".equalsIgnoreCase(pv.getProtocol())) { value = String.format("%d.%d localhost (Apache-HttpClient/%s (cache))", pv.getMajor(), pv.getMinor(), release); } else { value = String.format("%s/%d.%d localhost (Apache-HttpClient/%s (cache))", pv.getProtocol(), pv.getMajor(), pv.getMinor(), release); } viaHeaders.put(pv, value); return value; }
private String generateViaHeader(final HttpMessage msg) { final ProtocolVersion pv = msg.getProtocolVersion(); final String existingEntry = viaHeaders.get(pv); if (existingEntry != null) { return existingEntry; } final VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.client", getClass().getClassLoader()); final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE; String value; if ("http".equalsIgnoreCase(pv.getProtocol())) { value = String.format("%d.%d localhost (Apache-HttpClient/%s (cache))", pv.getMajor(), pv.getMinor(), release); } else { value = String.format("%s/%d.%d localhost (Apache-HttpClient/%s (cache))", pv.getProtocol(), pv.getMajor(), pv.getMinor(), release); } viaHeaders.put(pv, value); return value; }
private String generateViaHeader(final HttpMessage msg) { final ProtocolVersion pv = msg.getProtocolVersion(); final String existingEntry = viaHeaders.get(pv); if (existingEntry != null) { return existingEntry; } final VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.client", getClass().getClassLoader()); final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE; String value; if ("http".equalsIgnoreCase(pv.getProtocol())) { value = String.format("%d.%d localhost (Apache-HttpClient/%s (cache))", pv.getMajor(), pv.getMinor(), release); } else { value = String.format("%s/%d.%d localhost (Apache-HttpClient/%s (cache))", pv.getProtocol(), pv.getMajor(), pv.getMinor(), release); } viaHeaders.put(pv, value); return value; }
@Override protected HttpParams createHttpParams() { HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET); /* * Android note: Send each request body without first asking the server * whether it will be accepted. Asking first slows down the common case * and results in "417 expectation failed" errors when a HTTP/1.0 server * is behind a proxy. http://b/2471595 */ HttpProtocolParams.setUseExpectContinue(params, false); // android-changed // determine the release version from packaged version info final VersionInfo vi = VersionInfo.loadVersionInfo ("org.apache.http.client", getClass().getClassLoader()); final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE; HttpProtocolParams.setUserAgent(params, "Apache-HttpClient/" + release + " (java 1.4)"); return params; }
@Override protected HttpParams createHttpParams() { HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET); /* * Android note: Send each request body without first asking the server * whether it will be accepted. Asking first slows down the common case * and results in "417 expectation failed" errors when a HTTP/1.0 server * is behind a proxy. http://b/2471595 */ HttpProtocolParams.setUseExpectContinue(params, false); // android-changed // determine the release version from packaged version info final VersionInfo vi = VersionInfo.loadVersionInfo ("org.apache.http.client", getClass().getClassLoader()); final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE; HttpProtocolParams.setUserAgent(params, "Apache-HttpClient/" + release + " (java 1.4)"); return params; }
@Override protected HttpParams createHttpParams() { HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET); /* * Android note: Send each request body without first asking the server * whether it will be accepted. Asking first slows down the common case * and results in "417 expectation failed" errors when a HTTP/1.0 server * is behind a proxy. http://b/2471595 */ HttpProtocolParams.setUseExpectContinue(params, false); // android-changed // determine the release version from packaged version info final VersionInfo vi = VersionInfo.loadVersionInfo ("org.apache.http.client", getClass().getClassLoader()); final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE; HttpProtocolParams.setUserAgent(params, "Apache-HttpClient/" + release + " (java 1.4)"); return params; }
@Override protected HttpParams createHttpParams() { HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET); /* * Android note: Send each request body without first asking the server * whether it will be accepted. Asking first slows down the common case * and results in "417 expectation failed" errors when a HTTP/1.0 server * is behind a proxy. http://b/2471595 */ HttpProtocolParams.setUseExpectContinue(params, false); // android-changed // determine the release version from packaged version info final VersionInfo vi = VersionInfo.loadVersionInfo ("org.apache.http.client", getClass().getClassLoader()); final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE; HttpProtocolParams.setUserAgent(params, "Apache-HttpClient/" + release + " (java 1.4)"); return params; }