Example usage for org.apache.commons.httpclient HttpClient HttpClient

List of usage examples for org.apache.commons.httpclient HttpClient HttpClient

Introduction

In this page you can find the example usage for org.apache.commons.httpclient HttpClient HttpClient.

Prototype

public HttpClient(HttpClientParams paramHttpClientParams) 

Source Link

Usage

From source file:com.cloud.agent.direct.download.HttpDirectTemplateDownloader.java

public HttpDirectTemplateDownloader(String url, Long templateId, String destPoolPath, String checksum,
        Map<String, String> headers) {
    super(url, destPoolPath, templateId, checksum);
    s_httpClientManager.getParams().setConnectionTimeout(5000);
    s_httpClientManager.getParams().setSoTimeout(5000);
    client = new HttpClient(s_httpClientManager);
    request = createRequest(url, headers);
    String downloadDir = getDirectDownloadTempPath(templateId);
    createTemporaryDirectoryAndFile(downloadDir);
}

From source file:edu.harvard.i2b2.common.util.axis2.ServiceClient.java

public static String sendREST(String restEPR, OMElement request) throws Exception {

    String response = null;/*from   w  w  w  . ja v  a 2 s.co m*/
    org.apache.axis2.client.ServiceClient serviceClient = null;
    try {

        serviceClient = new org.apache.axis2.client.ServiceClient();

        ServiceContext context = serviceClient.getServiceContext();
        MultiThreadedHttpConnectionManager connManager = (MultiThreadedHttpConnectionManager) context
                .getProperty(HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER);

        if (connManager == null) {
            connManager = new MultiThreadedHttpConnectionManager();
            context.setProperty(HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER, connManager);
            connManager.getParams().setMaxTotalConnections(100);
            connManager.getParams().setMaxConnectionsPerHost(HostConfiguration.ANY_HOST_CONFIGURATION, 100);
        }
        HttpClient httpClient = new HttpClient(connManager);

        Options options = new Options();
        options.setTo(new EndpointReference(restEPR));
        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
        options.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE);
        options.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
        options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Constants.VALUE_TRUE);
        serviceClient.setOptions(options);

        OMElement result = serviceClient.sendReceive(request);
        if (result != null) {
            response = result.toString();
            log.debug(response);
        }
    } catch (Exception e) {
        log.debug("Cleanup Error .", e);
        e.printStackTrace();
        throw new I2B2Exception("" + StackTraceUtil.getStackTrace(e));
    } finally {
        if (serviceClient != null) {
            try {
                serviceClient.cleanupTransport();
                serviceClient.cleanup();
            } catch (AxisFault e) {
                log.debug("Error .", e);
            }
        }
    }

    return response;
}

From source file:edu.unc.lib.dl.fedora.FedoraAccessControlService.java

public FedoraAccessControlService() {
    this.multiThreadedHttpConnectionManager = new MultiThreadedHttpConnectionManager();
    this.httpClient = new HttpClient(this.multiThreadedHttpConnectionManager);
    this.mapper = new ObjectMapper();
}

From source file:de.ingrid.iplug.dsc.utils.BwstrLocUtil.java

private HttpClient createHttpClient() {
    HttpClient client = new HttpClient(new MultiThreadedHttpConnectionManager());
    if (System.getProperty("http.proxyHost") != null && System.getProperty("http.proxyPort") != null) {
        client.getHostConfiguration().setProxy(System.getProperty("http.proxyHost"),
                Integer.parseInt(System.getProperty("http.proxyPort")));
    }//from w w w .  j  av  a2s  .c  o m
    return client;
}

From source file:com.cognifide.actions.msg.push.active.PushClientRunnable.java

public PushClientRunnable(Set<PushReceiver> receivers, String serverUrl, String username, String password)
        throws URISyntaxException {
    this.receivers = receivers;
    this.serverUrl = serverUrl;

    final HttpConnectionManager connManager = new MultiThreadedHttpConnectionManager();
    client = new HttpClient(connManager);
    client.getParams().setAuthenticationPreemptive(true);
    final Credentials defaultcreds = new UsernamePasswordCredentials(username, password);
    final URI serverUri = new URI(serverUrl);
    final int port = serverUri.getPort() == -1 ? 80 : serverUri.getPort();
    client.getState().setCredentials(new AuthScope(serverUri.getHost(), port, AuthScope.ANY_REALM),
            defaultcreds);//  w w  w .  j  a va2  s .co m
}

From source file:com.fluidops.iwb.wiki.WikiBot.java

/**
 * /* ww w . j  a  va 2s.  c  om*/
 * @param wikimediaSource the wikimedia url, e.g. http://en.wikipedia.org/w/
 */
public WikiBot(String wikimediaSource) {
    this.wikimediaSource = wikimediaSource;
    httpClient = new HttpClient(new MultiThreadedHttpConnectionManager());
}

From source file:com.intellij.tasks.impl.BaseRepositoryImpl.java

private HttpClient createClient() {
    HttpClient client = new HttpClient(new MultiThreadedHttpConnectionManager());
    configureHttpClient(client);/* w ww .j a va2 s . c o  m*/
    return client;
}

From source file:com.adobe.translation.google.impl.TranslationServiceImpl.java

@Activate
protected void activate() {
    cxMgr = new MultiThreadedHttpConnectionManager();
    httpClient = new HttpClient(cxMgr);
}

From source file:edu.harvard.iq.dvn.core.web.dvnremote.DvnTermsOfUseAccess.java

private HttpClient getClient() {
    if (client == null) {
        client = new HttpClient(new MultiThreadedHttpConnectionManager());
    }/*from w  w w .j  a  v  a 2 s.co m*/
    return client;
    //return new HttpClient();
}

From source file:com.twistbyte.affiliate.HttpUtility.java

public HttpUtility() {

    MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();

    connectionManager.getParams().setDefaultMaxConnectionsPerHost(50);
    connectionManager.getParams().setMaxTotalConnections(50);

    httpclient = new HttpClient(connectionManager);

    // connect timeout in 8 seconds
    httpclient.getParams().setParameter("http.connection.timeout", new Integer(8000));
    httpclient.getParams().setParameter("http.socket.timeout", new Integer(300000));

    Protocol protocol = new Protocol("https", (ProtocolSocketFactory) new EasySSLProtocolSocketFactory(), 443);
    Protocol.registerProtocol("https", protocol);
}