本文整理汇总了Java中org.apache.http.client.protocol.ResponseContentEncoding类的典型用法代码示例。如果您正苦于以下问题:Java ResponseContentEncoding类的具体用法?Java ResponseContentEncoding怎么用?Java ResponseContentEncoding使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResponseContentEncoding类属于org.apache.http.client.protocol包,在下文中一共展示了ResponseContentEncoding类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getHttpClientBuilder
import org.apache.http.client.protocol.ResponseContentEncoding; //导入依赖的package包/类
public static HttpClientBuilder getHttpClientBuilder() {
// Common CacheConfig for both the JarCacheStorage and the underlying
// BasicHttpCacheStorage
final CacheConfig cacheConfig = CacheConfig.custom().setMaxCacheEntries(1000).setMaxObjectSize(1024 * 128)
.build();
RequestConfig config = RequestConfig.custom().setConnectTimeout(DEFAULT_TIMEOUT)
.setConnectionRequestTimeout(DEFAULT_TIMEOUT).setSocketTimeout(DEFAULT_TIMEOUT).build();
HttpClientBuilder clientBuilder = CachingHttpClientBuilder.create()
// allow caching
.setCacheConfig(cacheConfig)
// Wrap the local JarCacheStorage around a BasicHttpCacheStorage
.setHttpCacheStorage(new JarCacheStorage(null, cacheConfig, new BasicHttpCacheStorage(cacheConfig)))
// Support compressed data
// http://hc.apache.org/httpcomponents-client-ga/tutorial/html/httpagent.html#d5e1238
.addInterceptorFirst(new RequestAcceptEncoding()).addInterceptorFirst(new ResponseContentEncoding())
// use system defaults for proxy etc.
.useSystemProperties().setDefaultRequestConfig(config);
return clientBuilder;
}
示例2: createHttpProcessor
import org.apache.http.client.protocol.ResponseContentEncoding; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected BasicHttpProcessor createHttpProcessor() {
BasicHttpProcessor result = super.createHttpProcessor();
result.addRequestInterceptor(new RequestAcceptEncoding());
result.addResponseInterceptor(new ResponseContentEncoding());
return result;
}
示例3: createHttpProcessor
import org.apache.http.client.protocol.ResponseContentEncoding; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected BasicHttpProcessor createHttpProcessor() {
final BasicHttpProcessor result = super.createHttpProcessor();
result.addRequestInterceptor(new RequestAcceptEncoding());
result.addResponseInterceptor(new ResponseContentEncoding());
return result;
}
示例4: OppoMessenger
import org.apache.http.client.protocol.ResponseContentEncoding; //导入依赖的package包/类
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED")
public OppoMessenger(final String remoteHost, final int remotePort, final int localPort,
final HttpClientService httpClient)
throws IOException {
this.httpClient = httpClient;
// Set up the server
final HttpProcessor processor = HttpProcessorBuilder.create()
.add(new ResponseContent())
.add(new ResponseContentEncoding())
.add(new ResponseConnControl())
.build();
final HttpAsyncService service = new HttpAsyncService(processor, mapper);
final NHttpConnectionFactory<DefaultNHttpServerConnection> connectionFactory = new DefaultNHttpServerConnectionFactory(ConnectionConfig.DEFAULT);
final IOEventDispatch dispatch = new DefaultHttpServerIODispatch(service, connectionFactory);
server = new DefaultListeningIOReactor(IOReactorConfig.DEFAULT);
server.listen(new InetSocketAddress(localPort));
new Thread(new Runnable() {
@Override public void run() {
try {
server.execute(dispatch);
} catch (final IOException e) {
logger().level(Error).message("HTTP server failed").error(e).log();
}
}
}, "Oppo HTTP server");
// Set up the client
deviceUrlBase = "http://" + remoteHost + ':' + remotePort + '/';
}
示例5: prepareHttpClient
import org.apache.http.client.protocol.ResponseContentEncoding; //导入依赖的package包/类
private void prepareHttpClient(AbstractHttpClient client)
{
client.getParams().setParameter(ClientPNames.HANDLE_REDIRECTS, true);
client.addRequestInterceptor(new RequestAcceptEncoding());
client.addResponseInterceptor(new ResponseContentEncoding());
client.setRedirectStrategy(new BasicRedirectStrategy());
}
示例6: connect
import org.apache.http.client.protocol.ResponseContentEncoding; //导入依赖的package包/类
@Override
public void connect() throws IOException {
if (m_client != null) {
return;
}
final HttpParams httpParams = new BasicHttpParams();
if (m_request != null) {
int timeout = m_request.getParameterAsInt("timeout");
if (timeout > 0) {
HttpConnectionParams.setConnectionTimeout(httpParams, timeout);
HttpConnectionParams.setSoTimeout(httpParams, timeout);
}
}
m_client = new DefaultHttpClient(httpParams);
m_client.addRequestInterceptor(new RequestAcceptEncoding());
m_client.addResponseInterceptor(new ResponseContentEncoding());
if (m_request != null) {
int retries = m_request.getParameterAsInt("retries");
if (retries > 0) {
m_client.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler() {
@Override
public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
if (executionCount <= getRetryCount() && (exception instanceof SocketTimeoutException || exception instanceof ConnectTimeoutException)) {
return true;
}
return super.retryRequest(exception, executionCount, context);
}
});
}
String disableSslVerification = m_request.getParameter("disable-ssl-verification");
if (Boolean.parseBoolean(disableSslVerification)) {
final SchemeRegistry registry = m_client.getConnectionManager().getSchemeRegistry();
final Scheme https = registry.getScheme("https");
try {
SSLSocketFactory factory = new SSLSocketFactory(SSLContext.getInstance(EmptyKeyRelaxedTrustSSLContext.ALGORITHM), SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
final Scheme lenient = new Scheme(https.getName(), https.getDefaultPort(), factory);
registry.register(lenient);
} catch (NoSuchAlgorithmException e) {
log().warn(e.getMessage());
}
}
}
}
示例7: DecompressingHttpClient
import org.apache.http.client.protocol.ResponseContentEncoding; //导入依赖的package包/类
/**
* Constructs a decorator to ask for and handle compressed
* entities on the fly.
* @param backend the {@link HttpClient} to use for actually
* issuing requests
*/
public DecompressingHttpClient(HttpClient backend) {
this(backend, new RequestAcceptEncoding(), new ResponseContentEncoding());
}
示例8: DecompressingHttpClient
import org.apache.http.client.protocol.ResponseContentEncoding; //导入依赖的package包/类
/**
* Constructs a decorator to ask for and handle compressed
* entities on the fly.
* @param backend the {@link HttpClient} to use for actually
* issuing requests
*/
public DecompressingHttpClient(final HttpClient backend) {
this(backend, new RequestAcceptEncoding(), new ResponseContentEncoding());
}