Package org.apache.http.impl.client

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


   @Category(IgnoreForWildfly.class)
   public void testWrappedResponseStreamToGZip() throws Exception
   {

      DefaultHttpClient client = new DefaultHttpClient();
      client.addRequestInterceptor(new HttpRequestInterceptor()
      {

         @Override
         public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException
         {
View Full Code Here


        schReg.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        schReg.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
        ClientConnectionManager tsccm = new ThreadSafeClientConnManager(parameters, schReg);
       
        DefaultHttpClient defaultHttpClient = new DefaultHttpClient(tsccm, parameters);
        defaultHttpClient.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

      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) {
          client = null;
          sessionExpirationTime = -1L;
          throw new ManifoldCFException("getClient exception: " + ex.getMessage(), ex);
        }
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

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

      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) {
          client = null;
          sessionExpirationTime = -1L;
          throw new ManifoldCFException("getClient exception: " + ex.getMessage(), ex);
        }
View Full Code Here

    }

    DefaultHttpClient httpClient = new DefaultHttpClient();
    String httpUrl = hiveConfMap.get(HiveConf.ConfVars.HIVE_SERVER2_TRANSPORT_MODE.varname) +
        "://" + host + ":" + port + httpPath;
    httpClient.addRequestInterceptor(
        new HttpBasicAuthInterceptor(getUserName(), getPasswd())
        );
    try {
      transport = new THttpClient(httpUrl, httpClient);
    }
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

        // Suppose we already know the expected nonce value
        digestAuth.overrideParamter("nonce", "whatever");       
        localcontext.setAttribute("preemptive-auth", digestAuth);
       
        // Add as the first request interceptor
        httpclient.addRequestInterceptor(new PreemptiveAuth(), 0);
        // Add as the last response interceptor
        httpclient.addResponseInterceptor(new PersistentDigest());
       
        HttpHost targetHost = new HttpHost("localhost", 80, "http");
View Full Code Here

        // 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

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.