本文整理汇总了Java中org.apache.http.util.VersionInfo.getRelease方法的典型用法代码示例。如果您正苦于以下问题:Java VersionInfo.getRelease方法的具体用法?Java VersionInfo.getRelease怎么用?Java VersionInfo.getRelease使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.http.util.VersionInfo
的用法示例。
在下文中一共展示了VersionInfo.getRelease方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setDefaultHttpParams
import org.apache.http.util.VersionInfo; //导入方法依赖的package包/类
/**
* 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());
}
示例2: generateViaHeader
import org.apache.http.util.VersionInfo; //导入方法依赖的package包/类
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;
}
示例3: generateViaHeader
import org.apache.http.util.VersionInfo; //导入方法依赖的package包/类
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;
}
示例4: createHttpParams
import org.apache.http.util.VersionInfo; //导入方法依赖的package包/类
@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;
}
示例5: createDefaultHttpParams
import org.apache.http.util.VersionInfo; //导入方法依赖的package包/类
/**
* 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;
}
示例6: generateViaHeader
import org.apache.http.util.VersionInfo; //导入方法依赖的package包/类
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);
}
}
示例7: getFallbackDomain
import org.apache.http.util.VersionInfo; //导入方法依赖的package包/类
/**
* 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";
}
}
示例8: setDefaultHttpParams
import org.apache.http.util.VersionInfo; //导入方法依赖的package包/类
/**
* 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)");
}
示例9: getNaviHttpParams
import org.apache.http.util.VersionInfo; //导入方法依赖的package包/类
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;
}
示例10: getUserAgent
import org.apache.http.util.VersionInfo; //导入方法依赖的package包/类
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);
}
示例11: testVersion
import org.apache.http.util.VersionInfo; //导入方法依赖的package包/类
public void testVersion(){
VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.client",getClass().getClassLoader());
String version = vi.getRelease();
Log.d("apache http client version", version);
}