Example usage for org.apache.http.util VersionInfo UNAVAILABLE

List of usage examples for org.apache.http.util VersionInfo UNAVAILABLE

Introduction

In this page you can find the example usage for org.apache.http.util VersionInfo UNAVAILABLE.

Prototype

String UNAVAILABLE

To view the source code for org.apache.http.util VersionInfo UNAVAILABLE.

Click Source Link

Usage

From source file:org.vietspider.net.client.impl.AnonymousHttpClient.java

@Override
protected HttpParams createHttpParams() {
    HttpParams params = new BasicHttpParams();
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
    HttpProtocolParams.setUseExpectContinue(params, true);

    // 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;
}

From source file:com.jrodeo.queue.messageset.provider.TestHttpClient4.java

public String getClientName() {
    VersionInfo vinfo = VersionInfo.loadVersionInfo("org.apache.http.client",
            Thread.currentThread().getContextClassLoader());
    return "Apache HttpClient 4 (ver: " + ((vinfo != null) ? vinfo.getRelease() : VersionInfo.UNAVAILABLE)
            + ")";
}

From source file:com.jrodeo.remote.TestHttpCore.java

public String getClientName() {
    VersionInfo vinfo = VersionInfo.loadVersionInfo("org.apache.http",
            Thread.currentThread().getContextClassLoader());
    return "Apache HttpCore 4 (ver: " + ((vinfo != null) ? vinfo.getRelease() : VersionInfo.UNAVAILABLE) + ")";
}

From source file:org.iipg.hurricane.jmx.client.JMXClientBuilder.java

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;
}

From source file:com.apigee.sdk.apm.http.impl.client.cache.CachingHttpClient.java

private String generateViaHeader(HttpMessage msg) {
    final VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.client", getClass().getClassLoader());
    final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE;
    final ProtocolVersion pv = msg.getProtocolVersion();
    if ("http".equalsIgnoreCase(pv.getProtocol())) {
        return String.format("%d.%d localhost (Apache-HttpClient/%s (cache))", pv.getMajor(), pv.getMinor(),
                release);//from w  w  w. ja  v  a 2  s. co m
    } else {
        return String.format("%s/%d.%d localhost (Apache-HttpClient/%s (cache))", pv.getProtocol(),
                pv.getMajor(), pv.getMinor(), release);
    }
}

From source file:org.jets3t.service.utils.RestUtils.java

/**
 * Default Http parameters got from the DefaultHttpClient implementation.
 *
 * @return/*from   ww  w.  j a  v  a2s.c  o m*/
 * Default HTTP connection parameters
 */
public static HttpParams createDefaultHttpParams() {
    HttpParams params = new SyncBasicHttpParams();
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
    HttpConnectionParams.setTcpNoDelay(params, true);
    HttpConnectionParams.setSocketBufferSize(params, 8192);

    // determine the release version from packaged version info
    final VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.client",
            HttpClient.class.getClassLoader());
    final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE;
    HttpProtocolParams.setUserAgent(params, "Apache-HttpClient/" + release + " (java 1.5)");

    return params;
}

From source file:com.googlecode.sardine.impl.SardineImpl.java

/**
 * Creates default params setting the user agent.
 * /*from   w w  w.  j  a v  a2s. c  o m*/
 * @return Basic HTTP parameters with a custom user agent
 */
protected HttpParams createDefaultHttpParams() {
    HttpParams params = new BasicHttpParams();
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    String version = Version.getSpecification();
    if (version == null) {
        version = VersionInfo.UNAVAILABLE;
    }
    HttpProtocolParams.setUserAgent(params, "Sardine/" + version);
    // Only selectively enable this for PUT but not all entity enclosing
    // methods
    HttpProtocolParams.setUseExpectContinue(params, false);
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);

    HttpConnectionParams.setTcpNoDelay(params, true);
    HttpConnectionParams.setSocketBufferSize(params, 8192);
    return params;
}

From source file:com.github.sardine.impl.SardineImpl.java

/**
 * Creates a client with all of the defaults.
 *
 * @param selector    Proxy configuration or null
 * @param credentials Authentication credentials or null
 *//*from   w ww  . ja v  a2s .c o m*/
protected HttpClientBuilder configure(ProxySelector selector, CredentialsProvider credentials) {
    Registry<ConnectionSocketFactory> schemeRegistry = this.createDefaultSchemeRegistry();
    HttpClientConnectionManager cm = this.createDefaultConnectionManager(schemeRegistry);
    String version = Version.getSpecification();
    if (version == null) {
        version = VersionInfo.UNAVAILABLE;
    }
    return HttpClients.custom().setUserAgent("Sardine/" + version).setDefaultCredentialsProvider(credentials)
            .setRedirectStrategy(this.createDefaultRedirectStrategy())
            .setDefaultRequestConfig(RequestConfig.custom()
                    // Only selectively enable this for PUT but not all entity enclosing methods
                    .setExpectContinueEnabled(false).build())
            .setConnectionManager(cm)
            .setRoutePlanner(this.createDefaultRoutePlanner(this.createDefaultSchemePortResolver(), selector));
}

From source file:org.apache.http.impl.client.cache.CachingExec.java

private String generateViaHeader(final HttpMessage msg) {

    final ProtocolVersion pv = msg.getProtocolVersion();
    final String existingEntry = viaHeaders.get(pv);
    if (existingEntry != null) {
        return existingEntry;
    }/*  w ww . ja  v a  2  s. c o m*/

    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;
}

From source file:org.apache.http.impl.client.cache.CachingHttpAsyncClient.java

private String generateViaHeader(final HttpMessage msg) {

    final ProtocolVersion pv = msg.getProtocolVersion();
    final String existingEntry = viaHeaders.get(pv);
    if (existingEntry != null) {
        return existingEntry;
    }/* w w  w. ja  va 2 s  .c  o  m*/

    final VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.client", getClass().getClassLoader());
    final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE;

    final 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;
}