Code example for BasicHttpProcessor

Methods: BasicHttpProcessor.addInterceptor, addInterceptor, addRequestInterceptor

0
    this.delegate = new DefaultHttpClient(ccm, params) {
      @Override 
      protected BasicHttpProcessor createHttpProcessor() {
        // Add interceptor to prevent making requests from main thread. 
        BasicHttpProcessor processor = super.createHttpProcessor();
        processor.addRequestInterceptor(sThreadCheckInterceptor);
        return processor;
      } 
 
      @Override 
      protected HttpContext createHttpContext() {
        // Same as DefaultHttpClient.createHttpContext() minus the 
        // cookie store. 
        HttpContext context = new BasicHttpContext();
        context.setAttribute(ClientContext.AUTHSCHEME_REGISTRY, getAuthSchemes());
        context.setAttribute(ClientContext.COOKIESPEC_REGISTRY, getCookieSpecs());
        context.setAttribute(ClientContext.CREDS_PROVIDER, getCredentialsProvider());
        return context;
      } 
    }; 
  } 
 
  /** 
   * Release resources associated with this client.  You must call this, 
   * or significant resources (sockets and memory) may be leaked. 
   */ 
  public void close() { 
    getConnectionManager().shutdown();
  } 
 
  @Override 
public HttpParams getParams() {
    return delegate.getParams();
  } 
 
  @Override 
public ClientConnectionManager getConnectionManager() {
    return delegate.getConnectionManager();
  } 
 
  @Override 
public HttpResponse execute(HttpUriRequest request) throws IOException {
    return delegate.execute(request);
  } 
 
  @Override 
public HttpResponse execute(HttpUriRequest request, HttpContext context) throws IOException {
    return delegate.execute(request, context);
  } 
 
  @Override 
public HttpResponse execute(HttpHost target, HttpRequest request) throws IOException {
    return delegate.execute(target, request);
  } 
 
  @Override 
public HttpResponse execute(HttpHost target, HttpRequest request,
                              HttpContext context) throws IOException {
    return delegate.execute(target, request, context);
  } 
 
  @Override 
public <T> T execute(HttpUriRequest request, ResponseHandler<? extends T> responseHandler) throws IOException {
    return delegate.execute(request, responseHandler);
  } 
 
  @Override 
public <T> T execute(HttpUriRequest request, ResponseHandler<? extends T> responseHandler, HttpContext context)
      throws IOException { 
    return delegate.execute(request, responseHandler, context);
  } 
 
  @Override 
public <T> T execute(HttpHost target, HttpRequest request, ResponseHandler<? extends T> responseHandler)
      throws IOException { 
    return delegate.execute(target, request, responseHandler);
  } 
 
  @Override 
public <T> T execute(HttpHost target, HttpRequest request,
                       ResponseHandler<? extends T> responseHandler,
                       HttpContext context)
      throws IOException { 
    return delegate.execute(target, request, responseHandler, context);
  } 
 
}