/**
* Prints version information.
*
* @param args command line arguments. Leave empty to print version
* information for the default packages. Otherwise, pass
* a list of packages for which to get version info.
*/
public static void main(String args[]) {
String[] pckgs = (args.length > 0) ? args : MODULE_LIST;
VersionInfo[] via = VersionInfo.loadVersionInfo(pckgs, null);
System.out.println("version info for thread context classloader:");
for (int i=0; i<via.length; i++)
System.out.println(via[i]);
System.out.println();
// if the version information for the classloader of this class
// is different from that for the thread context classloader,
// there may be a problem with multiple versions in the classpath
via = VersionInfo.loadVersionInfo
(pckgs, PrintVersionInfo.class.getClassLoader());
System.out.println("version info for static classloader:");
for (int i=0; i<via.length; i++)
System.out.println(via[i]);
}
java类org.apache.http.util.VersionInfo的实例源码
PrintVersionInfo.java 文件源码
项目:PhET
阅读 13
收藏 0
点赞 0
评论 0
NaviHttpBasicConfig.java 文件源码
项目:navi
阅读 16
收藏 0
点赞 0
评论 0
/**
* Saves the default set of HttpParams in the provided parameter. These are:
* <ul>
* <li>{@link CoreProtocolPNames#PROTOCOL_VERSION}: 1.1</li>
* <li>{@link CoreProtocolPNames#HTTP_CONTENT_CHARSET}: ISO-8859-1</li>
* <li>{@link CoreConnectionPNames#TCP_NODELAY}: true</li>
* <li>{@link CoreConnectionPNames#SOCKET_BUFFER_SIZE}: 8192</li>
* <li>{@link CoreProtocolPNames#USER_AGENT}: Apache-HttpClient/<release>
* (java 1.5)</li>
* </ul>
*/
public void setDefaultHttpParams(HttpParams params) {
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
if (charset == null)
HttpProtocolParams.setContentCharset(params,
HTTP.DEF_CONTENT_CHARSET.name());
else
HttpProtocolParams.setContentCharset(params, 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",
DefaultHttpClient.class.getClassLoader());
final String release = (vi != null) ? vi.getRelease()
: VersionInfo.UNAVAILABLE;
if (getUserAgent() == null)
HttpProtocolParams.setUserAgent(params, "Navi-HttpClient/"
+ release + " (java 1.5, navi 2.x)");
else
HttpProtocolParams.setUserAgent(params, getUserAgent());
HttpConnectionParams.setConnectionTimeout(params, getConnectTimeout());
HttpConnectionParams.setSoTimeout(params, getSocketTimeout());
}
CachingHttpClient.java 文件源码
项目:purecloud-iot
阅读 21
收藏 0
点赞 0
评论 0
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;
}
CachingExec.java 文件源码
项目:purecloud-iot
阅读 19
收藏 0
点赞 0
评论 0
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;
final int major = pv.getMajor();
final int minor = pv.getMinor();
if ("http".equalsIgnoreCase(pv.getProtocol())) {
value = String.format("%d.%d localhost (Apache-HttpClient/%s (cache))", major, minor,
release);
} else {
value = String.format("%s/%d.%d localhost (Apache-HttpClient/%s (cache))", pv.getProtocol(), major,
minor, release);
}
viaHeaders.put(pv, value);
return value;
}
MinimalClientExec.java 文件源码
项目:purecloud-iot
阅读 18
收藏 0
点赞 0
评论 0
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 RequestContent(),
new RequestTargetHost(),
new RequestClientConnControl(),
new RequestUserAgent(VersionInfo.getUserAgent(
"Apache-HttpClient", "org.apache.http.client", getClass())));
this.requestExecutor = requestExecutor;
this.connManager = connManager;
this.reuseStrategy = reuseStrategy;
this.keepAliveStrategy = keepAliveStrategy;
}
DefaultHttpClient.java 文件源码
项目:cJUnit-mc626
阅读 20
收藏 0
点赞 0
评论 0
@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);
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", getClass().getClassLoader());
final String release = (vi != null) ?
vi.getRelease() : VersionInfo.UNAVAILABLE;
HttpProtocolParams.setUserAgent(params,
"Apache-HttpClient/" + release + " (java 1.5)");
return params;
}
RestUtils.java 文件源码
项目:jets3t-aws-roles
阅读 20
收藏 0
点赞 0
评论 0
/**
* Default Http parameters got from the DefaultHttpClient implementation.
*
* @return
* 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;
}
CachingHttpClient.java 文件源码
项目:apigee-android-sdk
阅读 22
收藏 0
点赞 0
评论 0
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);
} else {
return String.format(
"%s/%d.%d localhost (Apache-HttpClient/%s (cache))",
pv.getProtocol(), pv.getMajor(), pv.getMinor(), release);
}
}
APIClient.java 文件源码
项目:algoliasearch-client-java
阅读 30
收藏 0
点赞 0
评论 0
/**
* 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() {
String version = System.getProperty("java.version");
int pos = version.indexOf('.');
pos = version.indexOf('.', pos + 1);
boolean javaHasSNI = Double.parseDouble(version.substring(0, pos)) >= 1.7;
final VersionInfo vi = VersionInfo.loadVersionInfo
("org.apache.http.client", APIClient.class.getClassLoader());
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";
}
}
DefaultHttpClient.java 文件源码
项目:lams
阅读 16
收藏 0
点赞 0
评论 0
/**
* Saves the default set of HttpParams in the provided parameter.
* These are:
* <ul>
* <li>{@link CoreProtocolPNames#PROTOCOL_VERSION}: 1.1</li>
* <li>{@link CoreProtocolPNames#HTTP_CONTENT_CHARSET}: ISO-8859-1</li>
* <li>{@link CoreConnectionPNames#TCP_NODELAY}: true</li>
* <li>{@link CoreConnectionPNames#SOCKET_BUFFER_SIZE}: 8192</li>
* <li>{@link CoreProtocolPNames#USER_AGENT}: Apache-HttpClient/<release> (java 1.5)</li>
* </ul>
*/
public static void setDefaultHttpParams(HttpParams params) {
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, HTTP.DEF_CONTENT_CHARSET.name());
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", DefaultHttpClient.class.getClassLoader());
final String release = (vi != null) ?
vi.getRelease() : VersionInfo.UNAVAILABLE;
HttpProtocolParams.setUserAgent(params,
"Apache-HttpClient/" + release + " (java 1.5)");
}
NaviHttpClientDriver.java 文件源码
项目:navi
阅读 20
收藏 0
点赞 0
评论 0
private HttpParams getNaviHttpParams(NaviHttpPoolConfig httpPoolConfig) {
params = new SyncBasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
if (httpPoolConfig.getCharset() == null) {
HttpProtocolParams.setContentCharset(params, HTTP.DEF_CONTENT_CHARSET.name());
} else {
HttpProtocolParams.setContentCharset(params, httpPoolConfig.getCharset());
}
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", DefaultHttpClient.class.getClassLoader());
final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE;
if (httpPoolConfig.getUserAgent() == null) {
HttpProtocolParams.setUserAgent(params, "Navi-HttpClient/" + release + " (java 1.5, navi 2.x)");
} else {
HttpProtocolParams.setUserAgent(params, httpPoolConfig.getUserAgent());
}
HttpConnectionParams.setConnectionTimeout(params, httpPoolConfig.getConnectTimeout());
HttpConnectionParams.setSoTimeout(params, httpPoolConfig.getSocketTimeout());
if (httpPoolConfig.getProxy() != null) {
try {
String[] connectionString = httpPoolConfig.getProxy().split(":");
HttpHost proxy = new HttpHost(connectionString[0], Integer.valueOf(connectionString[1]));
// Integer.getInteger(connectionString[1]));
params.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
} catch (Exception e) {
log.info(e.getMessage());
}
}
return params;
}
GoodData.java 文件源码
项目:gooddata-java
阅读 16
收藏 0
点赞 0
评论 0
private String getUserAgent() {
final Package pkg = Package.getPackage("com.gooddata");
final String clientVersion = pkg != null && pkg.getImplementationVersion() != null
? pkg.getImplementationVersion() : UNKNOWN_VERSION;
final VersionInfo vi = loadVersionInfo("org.apache.http.client", HttpClientBuilder.class.getClassLoader());
final String apacheVersion = vi != null ? vi.getRelease() : UNKNOWN_VERSION;
return String.format("%s/%s (%s; %s) %s/%s", "GoodData-Java-SDK", clientVersion,
System.getProperty("os.name"), System.getProperty("java.specification.version"),
"Apache-HttpClient", apacheVersion);
}
ApacheProduct.java 文件源码
项目:http-client-essentials-suite
阅读 15
收藏 0
点赞 0
评论 0
@Override
public void appendTo(StringBuilder sb)
{
sb.append(VersionInfo.getUserAgent("Apache-HttpClient",
"org.apache.http.client", HttpClient.class));
}
RestClientHelper.java 文件源码
项目:vso-intellij
阅读 19
收藏 0
点赞 0
评论 0
public static ClientConfig getClientConfig(final ServerContext.Type type,
final Credentials credentials,
final String serverUri,
final boolean includeProxySettings) {
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, credentials);
final ConnectorProvider connectorProvider = new ApacheConnectorProvider();
// custom json provider ignores new fields that aren't recognized
final JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
final ClientConfig clientConfig = new ClientConfig(jacksonJsonProvider).connectorProvider(connectorProvider);
clientConfig.property(ApacheClientProperties.CREDENTIALS_PROVIDER, credentialsProvider);
clientConfig.property(ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.BUFFERED);
// For TFS OnPrem we only support NTLM authentication right now. Since 2016 servers support Basic as well,
// we need to let the server and client negotiate the protocol instead of preemptively assuming Basic.
// TODO: This prevents PATs from being used OnPrem. We need to fix this soon to support PATs onPrem.
clientConfig.property(ApacheClientProperties.PREEMPTIVE_BASIC_AUTHENTICATION, type != ServerContext.Type.TFS);
//Define a local HTTP proxy
if (includeProxySettings) {
final HttpProxyService proxyService = PluginServiceProvider.getInstance().getHttpProxyService();
final String proxyUrl = proxyService.getProxyURL();
clientConfig.property(ClientProperties.PROXY_URI, proxyUrl);
if (proxyService.isAuthenticationRequired()) {
// To work with authenticated proxies and TFS, we provide the proxy credentials if they are registered
final AuthScope ntlmAuthScope =
new AuthScope(proxyService.getProxyHost(), proxyService.getProxyPort(),
AuthScope.ANY_REALM, AuthScope.ANY_SCHEME);
credentialsProvider.setCredentials(ntlmAuthScope,
new UsernamePasswordCredentials(proxyService.getUserName(), proxyService.getPassword()));
}
}
// if this is a onPrem server and the uri starts with https, we need to setup ssl
if (isSSLEnabledOnPrem(type, serverUri)) {
clientConfig.property(ApacheClientProperties.SSL_CONFIG, getSslConfigurator());
}
// register a filter to set the User Agent header
clientConfig.register(new ClientRequestFilter() {
@Override
public void filter(final ClientRequestContext requestContext) throws IOException {
// The default user agent is something like "Jersey/2.6"
final String defaultUserAgent = VersionInfo.getUserAgent("Apache-HttpClient", "org.apache.http.client", HttpClientBuilder.class);
// We get the user agent string from the Telemetry context
final String userAgent = PluginServiceProvider.getInstance().getTelemetryContextInitializer().getUserAgent(defaultUserAgent);
// Finally, we can add the header
requestContext.getHeaders().add(HttpHeaders.USER_AGENT, userAgent);
}
});
return clientConfig;
}
DownloadManagerImpl.java 文件源码
项目:incubator-taverna-osgi
阅读 16
收藏 0
点赞 0
评论 0
public String getUserAgent() {
Package pack = getClass().getPackage();
String httpClientVersion = VersionInfo.getUserAgent("Apache-HttpClient", "org.apache.http.client",
Request.class);
return "Apache-Taverna-OSGi" + "/" + pack.getImplementationVersion() + " (" + httpClientVersion + ")";
}
ApacheTest.java 文件源码
项目:sana.mobile
阅读 14
收藏 0
点赞 0
评论 0
public void testVersion(){
VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.client",getClass().getClassLoader());
String version = vi.getRelease();
Log.d("apache http client version", version);
}
DefaultHttpClient.java 文件源码
项目:purecloud-iot
阅读 30
收藏 0
点赞 0
评论 0
/**
* Saves the default set of HttpParams in the provided parameter.
* These are:
* <ul>
* <li>{@link org.apache.http.params.CoreProtocolPNames#PROTOCOL_VERSION}:
* 1.1</li>
* <li>{@link org.apache.http.params.CoreProtocolPNames#HTTP_CONTENT_CHARSET}:
* ISO-8859-1</li>
* <li>{@link org.apache.http.params.CoreConnectionPNames#TCP_NODELAY}:
* true</li>
* <li>{@link org.apache.http.params.CoreConnectionPNames#SOCKET_BUFFER_SIZE}:
* 8192</li>
* <li>{@link org.apache.http.params.CoreProtocolPNames#USER_AGENT}:
* Apache-HttpClient (Java 1.5)</li>
* </ul>
*/
public static void setDefaultHttpParams(final HttpParams params) {
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, HTTP.DEF_CONTENT_CHARSET.name());
HttpConnectionParams.setTcpNoDelay(params, true);
HttpConnectionParams.setSocketBufferSize(params, 8192);
HttpProtocolParams.setUserAgent(params, VersionInfo.getUserAgent("Apache-HttpClient",
"org.apache.http.client", DefaultHttpClient.class));
}