Examples of DefaultHttpClient


Examples of org.apache.http.impl.client.DefaultHttpClient

{
   protected HttpClient httpClient;

   public ApacheHttpClient4Executor()
   {
      this.httpClient = new DefaultHttpClient();
   }
View Full Code Here

Examples of org.apache.http.impl.client.DefaultHttpClient

    updateProperties("Last action: added accessToken");
  }

  public class SingleClient implements HttpClientPool {
    SingleClient() {
      org.apache.http.client.HttpClient client = new DefaultHttpClient();
      ClientConnectionManager mgr = client.getConnectionManager();
      if (!(mgr instanceof ThreadSafeClientConnManager)) {
        HttpParams params = client.getParams();
        client = new DefaultHttpClient(new ThreadSafeClientConnManager(
            params, mgr.getSchemeRegistry()), params);
      }

      // Use Proxy to access if you are in one of the countries that cannot connects to twitter directly.  
      // HttpHost proxy = new HttpHost("your_proxy_url", your_proxy_port);
View Full Code Here

Examples of org.apache.http.impl.client.DefaultHttpClient

    for (Status status : statuses.status)
      System.out.println(status);
  }

  private static HttpClient createClient() {
    HttpClient httpClient = new DefaultHttpClient();
       
    // Use Proxy to access if you are in one of the countries that cannot connects to twitter directly.  
//    HttpHost proxy = new HttpHost("your_proxy_url", your_proxy_port);
//    httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
//        proxy);
View Full Code Here

Examples of org.apache.http.impl.client.DefaultHttpClient

      // Create an HttpClient with the ThreadSafeClientConnManager.
      // This connection manager must be used if more than one thread will
      // be using the HttpClient.
      ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);
      HttpClient httpClient = new DefaultHttpClient(cm, params);

      final ApacheHttpClient4Executor executor = new ApacheHttpClient4Executor(httpClient);
      return executor;
   }
View Full Code Here

Examples of org.apache.http.impl.client.DefaultHttpClient

    // conserve bandwidth by minimizing the number of segments that are sent
    HttpConnectionParams.setTcpNoDelay(httpParams, false);
    // Defines whether the socket can be bound even though a previous connection is still in a timeout state.
    HttpConnectionParams.setSoReuseaddr(httpParams, true);

    httpClient = new DefaultHttpClient(clientConnectionManager, httpParams);
    // ask for gzip
    ((AbstractHttpClient) httpClient).addRequestInterceptor(new GzipRequestInterceptor());
    // uncompress gzip
    ((AbstractHttpClient) httpClient).addResponseInterceptor(new GzipResponseInterceptor());
View Full Code Here

Examples of org.apache.http.impl.client.DefaultHttpClient

        oHndlr.writeTo(oStrm);
        aRetVal = oStrm.toByteArray();
        oStrm.close();
      } else {
      if (null==oHttpCli) {
        oHttpCli = new DefaultHttpClient();
      } // fi (oHttpCli)

    oHttpCli.getCredentialsProvider().setCredentials(new AuthScope(oUrl.getHost(), AuthScope.ANY_PORT, realm()),
                             new UsernamePasswordCredentials(user(), password()));       
      HttpGet oGet = null;
View Full Code Here

Examples of org.apache.http.impl.client.DefaultHttpClient

        oHndlr.writeTo(oStrm);
        sRetVal = oStrm.toString(sEncoding);
        oStrm.close();
    } else {
      if (null==oHttpCli) {       
        oHttpCli = new DefaultHttpClient();
      } // fi (oHttpCli)
    oHttpCli.getCredentialsProvider().setCredentials(new AuthScope(oUrl.getHost(), AuthScope.ANY_PORT, realm()),
                             new UsernamePasswordCredentials(user(), password()));       
      HttpGet oGet = null;
      try {
View Full Code Here

Examples of org.apache.http.impl.client.DefaultHttpClient

    String response = getHttpClient().execute(method, responseHandler);
    return response;
  }

  public static HttpClient getHttpClient() {
    DefaultHttpClient httpClient = new DefaultHttpClient();

    final UserPreferences userPreferences = UserPreferences.getInstance();
    if (userPreferences.isProxyEnabled()) {
      // set up HTTP proxy
      final String proxyHostname = userPreferences.getProxyHostname();
      final int proxyPort = userPreferences.getProxyPort();

      final HttpHost proxy = new HttpHost(proxyHostname, proxyPort);
      httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);

      if (userPreferences.isProxyAuthenticationEnabled()) {
        final AuthScope authScope = new AuthScope(proxyHostname, proxyPort);
        final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(
            userPreferences.getProxyUsername(), userPreferences.getProxyPassword());
        httpClient.getCredentialsProvider().setCredentials(authScope, credentials);
      }
    }

    return httpClient;
  }
View Full Code Here

Examples of org.apache.http.impl.client.DefaultHttpClient

    // WARNING
    // I had to disable "Expect: 100-Continue" header since I had
    // two second delay between sending http POST request and POST body
    httpParams = postMethod.getParams();
    HttpProtocolParams.setUseExpectContinue(httpParams, false);
    this.client = new DefaultHttpClient(new ThreadSafeClientConnManager(httpParams, registry), httpParams);
  }
View Full Code Here

Examples of org.apache.http.impl.client.DefaultHttpClient

    channel.stop();
  }

  @Before
  public void setUp() {
    httpClient = new DefaultHttpClient();
    postRequest = new HttpPost("http://0.0.0.0:41404");
  }
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.