private HttpClient getHttpClient() {
   DefaultHttpClient client = new DefaultHttpClient();
   client.setReuseStrategy(
       new ConnectionReuseStrategy() {
         @Override
         public boolean keepAlive(HttpResponse httpResponse, HttpContext httpContext) {
           return false;
         }
       });
   return client;
 }
示例#2
0
  public CloudAppImpl(String mail, String pw) {
    DefaultHttpClient client = new DefaultHttpClient();
    client.setReuseStrategy(new DefaultConnectionReuseStrategy());

    // Try to authenticate.
    AuthScope scope = new AuthScope("my.cl.ly", 80);
    client
        .getCredentialsProvider()
        .setCredentials(scope, new UsernamePasswordCredentials(mail, pw));
    LOGGER.debug("Authentication set.");

    account = new AccountImpl(client);
    items = new CloudAppItemsImpl(client);
  }
 private void setKeepAlive(DefaultHttpClient httpClient) {
   // 10 seconds keepalive
   httpClient.setReuseStrategy(
       new ConnectionReuseStrategy() {
         @Override
         public boolean keepAlive(HttpResponse arg0, HttpContext arg1) {
           return true;
         }
       });
   httpClient.setKeepAliveStrategy(
       new ConnectionKeepAliveStrategy() {
         @Override
         public long getKeepAliveDuration(HttpResponse arg0, HttpContext arg1) {
           return DEFAULT_KEEP_LIVE;
         }
       });
 }
示例#4
0
 public CloudAppImpl() {
   DefaultHttpClient client = new DefaultHttpClient();
   client.setReuseStrategy(new DefaultConnectionReuseStrategy());
   account = new AccountImpl(client);
   items = new CloudAppItemsImpl(client);
 }