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

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

Introduction

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

Prototype

public int executeMethod(HostConfiguration paramHostConfiguration, HttpMethod paramHttpMethod,
              HttpState paramHttpState) throws IOException, HttpException 

Source Link

Usage

From source file:com.zimbra.common.httpclient.HttpClientUtil.java

public static int executeMethod(HttpClient client, HttpMethod method, HttpState state)
        throws HttpException, IOException {
    ProxyHostConfiguration proxyConfig = HttpProxyConfig.getProxyConfig(client.getHostConfiguration(),
            method.getURI().toString());
    if (proxyConfig != null && proxyConfig.getUsername() != null && proxyConfig.getPassword() != null) {
        if (state == null) {
            state = client.getState();/*from   ww w  .j a  va2 s . c o m*/
            if (state == null) {
                state = new HttpState();
            }
        }
        state.setProxyCredentials(new AuthScope(proxyConfig.getHost(), proxyConfig.getPort()),
                new UsernamePasswordCredentials(proxyConfig.getUsername(), proxyConfig.getPassword()));
    }
    return client.executeMethod(proxyConfig, method, state);
}