Package org.apache.http

Examples of org.apache.http.HttpRequestInterceptor


        this.targetState.setState(AuthProtocolState.CHALLENGED);
        this.targetState.update(new BasicScheme(), new UsernamePasswordCredentials("user3", "secret3"));
        this.proxyState.setState(AuthProtocolState.CHALLENGED);
        this.proxyState.update(new BasicScheme(), new UsernamePasswordCredentials("user4", "secret4"));

        final HttpRequestInterceptor interceptor = new RequestAuthCache();
        interceptor.process(request, context);
        Assert.assertNotSame(this.authscheme1, this.targetState.getAuthScheme());
        Assert.assertNotSame(this.creds1, this.targetState.getCredentials());
        Assert.assertNotSame(this.authscheme2, this.proxyState.getAuthScheme());
        Assert.assertNotSame(this.creds2, this.proxyState.getCredentials());
    }
View Full Code Here


    // try resending the request once
    client.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(1, true));

    // Add hooks for gzip/deflate
    client.addRequestInterceptor(new HttpRequestInterceptor() {
      public void process(
          final org.apache.http.HttpRequest request,
          final HttpContext context) throws HttpException, IOException {
        if (!request.containsHeader("Accept-Encoding")) {
          request.addHeader("Accept-Encoding", "gzip, deflate");
View Full Code Here

  @Override
  public void initialize(DefaultHttpClient httpClient) throws ClientServicesException {
    try {
      AccessToken token = oAuthHandler.acquireToken(false);
      if ((token != null) && (oAuthHandler != null)) {
        HttpRequestInterceptor oauthInterceptor = new OAuthInterceptor(token, super.getUrl(),oAuthHandler);
        httpClient.addRequestInterceptor(oauthInterceptor, 0);
      }
    } catch (OAuthException ex) {
      throw new ClientServicesException(ex);
    }
View Full Code Here

    public void redirect() {
    }

    @Override
  public void initialize(DefaultHttpClient httpClient) {
        HttpRequestInterceptor ltpaInterceptor = new LtpaInterceptor(getUrl(), getDomain());
        httpClient.addRequestInterceptor(ltpaInterceptor, 0);
    }
View Full Code Here

  }

  @Override
  public void initialize(DefaultHttpClient httpClient)throws ClientServicesException {
    if (StringUtil.isNotEmpty(getCookieCache())) {
      HttpRequestInterceptor basicInterceptor = new CookieInterceptor(getCookieCache());
      httpClient.addRequestInterceptor(basicInterceptor, 0);
    }
  }
View Full Code Here

   */
  public void initialize(DefaultHttpClient httpClient) throws ClientServicesException {
    try {
      AccessToken accesstoken = oAuthHandler.acquireToken(false);
      if (accesstoken != null) {
        HttpRequestInterceptor oauthInterceptor = new OAuth2Interceptor(accesstoken);
        httpClient.addRequestInterceptor(oauthInterceptor, 0);
      }
    } catch (OAuthException e) {}
  }
View Full Code Here

          if(StringUtil.isNotEmpty(usr)) {
              String pwd = getPassword();
             
              UsernamePasswordCredentials creds = new UsernamePasswordCredentials(usr,pwd);
             
              HttpRequestInterceptor basicInterceptor = new BasicInterceptor(creds);
              httpClient.addRequestInterceptor(basicInterceptor, 0);
          }
      }
View Full Code Here

        if(StringUtil.isNotEmpty(usr)) {
            String pwd = getPassword();
           
            UsernamePasswordCredentials creds = new UsernamePasswordCredentials(usr,pwd);
           
            HttpRequestInterceptor basicInterceptor = new BasicInterceptor(creds);
            httpClient.addRequestInterceptor(basicInterceptor, 0);
        }
    }
View Full Code Here

    }

    protected HttpClient createHttpClient() {
        DefaultHttpClient client = new DefaultHttpClient(new ThreadSafeClientConnManager());
        if (useCompression) {
            client.addRequestInterceptor( new HttpRequestInterceptor() {
                @Override
                public void process(HttpRequest request, HttpContext context) {
                    // We expect to received a compression response that we un-gzip
                    request.addHeader("Accept-Encoding", "gzip");
                }
View Full Code Here

        int port = this.localServer.getServicePort();
        this.localServer.register("*", new SimpleService());
       
        FaultyHttpClient client = new FaultyHttpClient();
       
        client.addRequestInterceptor(new HttpRequestInterceptor() {

            public void process(
                    final HttpRequest request,
                    final HttpContext context) throws HttpException, IOException {
                request.addHeader("my-header", "stuff");
View Full Code Here

TOP

Related Classes of org.apache.http.HttpRequestInterceptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.