Package org.apache.http.impl.client

Examples of org.apache.http.impl.client.DefaultHttpClient.addRequestInterceptor()


        // execution context
        BasicScheme basicAuth = new BasicScheme();
        localcontext.setAttribute("preemptive-auth", basicAuth);
       
        // Add as the first request interceptor
        httpclient.addRequestInterceptor(new PreemptiveAuth(), 0);
       
        HttpHost targetHost = new HttpHost("localhost", 80, "http");

        HttpGet httpget = new HttpGet("/");
View Full Code Here


        String msg =  "Could not create an https connection to " +
            jdbcUriString + ". " + e.getMessage();
        throw new SQLException(msg, " 08S01", e);
      }
    }
    httpClient.addRequestInterceptor(requestInterceptor);
    return httpClient;
  }

  /**
   * Create transport per the connection options
View Full Code Here

          new AuthScope(apiURL.getHost(), apiURL.getPort(),
              AuthScope.ANY_REALM),
              new UsernamePasswordCredentials(mUser, mPassword));
      BasicHttpContext localcontext = new BasicHttpContext();
      localcontext.setAttribute("preemptive-auth", new BasicScheme());
      httpClient.addRequestInterceptor(new PreemptiveAuth(), 0);
      HttpPost request = new HttpPost(url);
      ObjectMapper mapper = new ObjectMapper();
      StringEntity params = new StringEntity(mapper.writeValueAsString(new Body(body)));
      request.addHeader("Content-Type", "application/json");
      request.setEntity(params);
View Full Code Here

public class ClientGZipContentCompression {

    public final static void main(String[] args) throws Exception {
        DefaultHttpClient httpclient = new DefaultHttpClient();

        httpclient.addRequestInterceptor(new HttpRequestInterceptor() {
          
            public void process(
                    final HttpRequest request,
                    final HttpContext context) throws HttpException, IOException {
                if (!request.containsHeader("Accept-Encoding")) {
View Full Code Here

        DefaultHttpClient client = new DefaultHttpClient(m_cManager);
        client.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, TIMEOUT_SECONDS * 1000);
        UsernamePasswordCredentials creds = getCreds(url);
        if (creds != null) {
            client.getCredentialsProvider().setCredentials(AuthScope.ANY, creds);
            client.addRequestInterceptor(new PreemptiveAuth());
        }
        client.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, true);
        HttpInputStream in = new HttpInputStream(client, getMethod);
        if (in.getStatusCode() != 200) {
            try {
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

    if (genericLogin != null && !genericLogin.isEmpty()) {
      try {
        URL url = new URL(genericEntryPoint);
        Credentials credentials = new UsernamePasswordCredentials(genericLogin, genericPassword);
        cl.getCredentialsProvider().setCredentials(new AuthScope(url.getHost(), url.getPort() > 0 ? url.getPort() : 80, AuthScope.ANY_REALM), credentials);
        cl.addRequestInterceptor(new PreemptiveAuth(credentials), 0);
      } catch (MalformedURLException ex) {
        throw new ManifoldCFException("getClient exception: " + ex.getMessage(), ex);
      }
    }
    HttpConnectionParams.setConnectionTimeout(cl.getParams(), connectionTimeoutMillis);
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

        }
      };
    }
    client.setHttpRequestRetryHandler(retryHandler);

    client.addRequestInterceptor(new HttpRequestInterceptor()
    {
      public void process(final HttpRequest request, final HttpContext context)
        throws HttpException, IOException
      {
        if (!request.containsHeader("Accept-Encoding"))
View Full Code Here

        protected ConnectionReuseStrategy createConnectionReuseStrategy() {
          return new DBConnectionReuseStrategy();
        }
      };

      c.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");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.