AbstractHttpClient addResponseInterceptor - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for AbstractHttpClient addResponseInterceptor method.

This code example shows how to use the following methods:addRequestInterceptor, addResponseInterceptor, setHttpRequestRetryHandler
8
CodeRank
This code example shows how to use the following methods:addRequestInterceptor, addResponseInterceptor, getParams, setHttpRequestRetryHandler
        context.setHttpResponse(response);
        return context;
    } 
     
    private static DefaultHttpClient getHttpClient(HttpInvocationContext context) {
        DefaultHttpClient client = new DefaultHttpClient();
        HttpParams params = client.getParams();
        HttpConnectionParams.setConnectionTimeout(params, 30000);
        HttpConnectionParams.setSoTimeout(params, 30000);
        client.setHttpRequestRetryHandler(new HttpRequestRetryHandler() {                     
            public boolean retryRequest(IOException e, int i, HttpContext httpContext) {
                return false; 
            } 
        });   
        client.addRequestInterceptor(context);
        client.addResponseInterceptor(context);
        return client;
    } 
     
} 
7
CodeRank
This code example shows how to use the following methods:addRequestInterceptor, addResponseInterceptor, setHttpRequestRetryHandler
7
CodeRank
This code example shows how to use the following methods:addRequestInterceptor, addResponseInterceptor, setHttpRequestRetryHandler
			HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
			HttpProtocolParams.setUseExpectContinue(params, true);
			 
			ThreadSafeClientConnManager connectionManager = new ThreadSafeClientConnManager(params, schemeRegistry);
			 
			httpClient = new DefaultHttpClient(connectionManager, params);
			httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(3, false));
			httpClient.addRequestInterceptor(new HttpRequestInterceptor() 
			{ 
	            public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException 
	            { 
	                if (!request.containsHeader("Accept-Encoding")) 
	                { 
	                    request.addHeader("Accept-Encoding", "gzip");
	                } 
	            } 
	        }); 
			httpClient.addResponseInterceptor(new HttpResponseInterceptor() 
			{ 
	            public void process(final HttpResponse response, final HttpContext context) throws HttpException, IOException 

6
CodeRank
This code example shows how to use the following methods:addRequestInterceptor, addResponseInterceptor, setHttpRequestRetryHandler
6
CodeRank
This code example shows how to use the following methods:addRequestInterceptor, addResponseInterceptor
        HttpConnectionParams.setSoTimeout(params, 20 * SECOND_IN_MILLIS);
 
        HttpConnectionParams.setSocketBufferSize(params, 8192);
        HttpProtocolParams.setUserAgent(params, buildUserAgent(context));
 
        final DefaultHttpClient client = new DefaultHttpClient(params);
 
        client.addRequestInterceptor(new HttpRequestInterceptor() {
            public void process(HttpRequest request, HttpContext context) {
                // Add header to accept gzip content 
                if (!request.containsHeader(HEADER_ACCEPT_ENCODING)) {
                    request.addHeader(HEADER_ACCEPT_ENCODING, ENCODING_GZIP);
                } 
            } 
        }); 
 
        client.addResponseInterceptor(new HttpResponseInterceptor() {
            public void process(HttpResponse response, HttpContext context) {
                // Inflate any responses compressed with gzip 
                final HttpEntity entity = response.getEntity();

6
CodeRank
This code example shows how to use the following methods:addRequestInterceptor, addResponseInterceptor
This code example shows how to use the following methods:addRequestInterceptor, addResponseInterceptor
	return is;
    } 
 
    private static DefaultHttpClient getDefaultHttpClient(ClientConnectionManager conMgr, HttpParams params, 
							 boolean useHttps) {
	DefaultHttpClient client = new DefaultHttpClient(conMgr, params);
	if ( UIUtil.isAfterEclair() || useHttps == false ) // will use default client in froyo...
	    return client;
	Log.d(TAG, "try to use more tolarate http client");
	// for earlier android that does not think *.domain cert is the same as domain cert... 
	SSLSocketFactory sslSocketFactory = (SSLSocketFactory) client
            .getConnectionManager().getSchemeRegistry().getScheme("https")
            .getSocketFactory();
 
	final X509HostnameVerifier delegate = sslSocketFactory.getHostnameVerifier();
	if(!(delegate instanceof MyVerifier)) {
	    sslSocketFactory.setHostnameVerifier(new MyVerifier(delegate));
	} 
 
	return client;

5
CodeRank
This code example shows how to use the following methods:addRequestInterceptor, addResponseInterceptor, setHttpRequestRetryHandler, setKeepAliveStrategy
    } 
 
    registry.register(new Scheme(_scheme, _port, sf)); 
 
    ClientConnectionManager cm = new ThreadSafeClientConnManager(registry); 
    DefaultHttpClient client = new DefaultHttpClient(cm, params); 
    if (retryHandler == null) 
    { 
      retryHandler = new HttpRequestRetryHandler() 
      { 
        public boolean retryRequest(IOException exception, int executionCount, HttpContext context) 
        { 
          if (executionCount >= _maxRetries) 
          { 
            // Do not retry if over max retry count 
            return false; 
          } 
          if (exception instanceof NoHttpResponseException) 
          { 
            // Retry if the server dropped connection on us 

5
CodeRank
This code example shows how to use the following methods:addRequestInterceptor, addResponseInterceptor
        HttpConnectionParams.setSoTimeout(params, 20 * SECOND_IN_MILLIS);
 
        HttpConnectionParams.setSocketBufferSize(params, 8192);
        HttpProtocolParams.setUserAgent(params, buildUserAgent(context));
 
        final DefaultHttpClient client = new DefaultHttpClient(params);
 
        client.addRequestInterceptor(new HttpRequestInterceptor() {
            public void process(HttpRequest request, HttpContext context) {
                // Add header to accept gzip content 
                if (!request.containsHeader(HEADER_ACCEPT_ENCODING)) {
                    request.addHeader(HEADER_ACCEPT_ENCODING, ENCODING_GZIP);
                } 
            } 
        }); 
 
        client.addResponseInterceptor(new HttpResponseInterceptor() {
            public void process(HttpResponse response, HttpContext context) {
                // Inflate any responses compressed with gzip 
                final HttpEntity entity = response.getEntity();

5
CodeRank

Related AbstractHttpClient addResponseInterceptor Questions & Answers: