org.apache.commons.httpclient

Class HttpClient


public class HttpClient
extends Object

An HTTP "user-agent", containing an HTTP state and one or more HTTP connections, to which HTTP methods can be applied.

Constructor Summary

HttpClient()
Creates an instance of HttpClient using default parameter set.
HttpClient(HttpConnectionManager httpConnectionManager)
Creates an instance of HttpClient with a user specified HTTP connection manager.
HttpClient(HttpClientParams params)
Creates an instance of HttpClient using the given parameter set.
HttpClient(HttpClientParams params, HttpConnectionManager httpConnectionManager)
Creates an instance of HttpClient with a user specified parameter set and HTTP connection manager.

Method Summary

int
executeMethod(HostConfiguration hostConfiguration, HttpMethod method)
Executes the given HTTP method using custom host configuration.
int
executeMethod(HostConfiguration hostconfig, HttpMethod method, HttpState state)
Executes the given HTTP method using the given custom host configuration with the given custom HTTP state.
int
executeMethod(HttpMethod method)
Executes the given HTTP method.
String
getHost()
Deprecated. use #getHostConfiguration()
HostConfiguration
getHostConfiguration()
Returns the host configuration associated with the HttpClient.
HttpConnectionManager
getHttpConnectionManager()
Returns the HTTP connection manager associated with the HttpClient.
HttpClientParams
getParams()
Returns HTTP protocol parameters associated with this HttpClient.
int
getPort()
Deprecated. use #getHostConfiguration()
HttpState
getState()
Returns HTTP state associated with the HttpClient.
boolean
isStrictMode()
Deprecated. Use HttpClientParams.getParameter(String) to exercise a more granular control over HTTP protocol strictness.
void
setConnectionTimeout(int newTimeoutInMilliseconds)
Deprecated. Use HttpConnectionManagerParams.setConnectionTimeout(int), HttpConnectionManager.getParams().
void
setHostConfiguration(HostConfiguration hostConfiguration)
Assigns the host configuration to use with the HttpClient.
void
setHttpConnectionFactoryTimeout(long timeout)
Deprecated. Use HttpClientParams.setConnectionManagerTimeout(long), getParams()
void
setHttpConnectionManager(HttpConnectionManager httpConnectionManager)
Assigns the HTTP connection manager to use with the HttpClient.
void
setParams(HttpClientParams params)
Assigns HTTP protocol parameters for this HttpClient.
void
setState(HttpState state)
Assigns HTTP state for the HttpClient.
void
setStrictMode(boolean strictMode)
Deprecated. Use HttpClientParams.setParameter(String,Object) to exercise a more granular control over HTTP protocol strictness.
void
setTimeout(int newTimeoutInMilliseconds)
Deprecated. Use HttpConnectionManagerParams.setSoTimeout(int), HttpConnectionManager.getParams().

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

HttpClient

public HttpClient()
Creates an instance of HttpClient using default parameter set.
Usages and Demos :

View More Examples of HttpClient()
   1:     public static void main(String[] args) throws HttpException, IOException {
   2:         HttpClient client = new HttpClient();
   3:     
   4:         System.out.println( "Making Request without Cookie: " );
   5:         makeRequest(client);

View Full Code Here
   1:     try {
   2:       HttpClient client = new HttpClient();
   3:       client.getHostConfiguration().setHost("uonline.utah.edu", 80, "http");
   4:       client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
   5:       GetMethod get = new GetMethod("/main/jsps/announcements.jsp");

View Full Code Here
   1:         
   2:         HttpClient client = new HttpClient();
   3:         client.executeMethod(head);
   4:         
   5:         int status = head.getStatusCode();

View Full Code Here
   1:     public static void main(String[] args) throws HttpException, IOException {
   2:         HttpClient client = new HttpClient();
   3:         HttpMethod method = new GetMethod( url );
   4:         client.executeMethod( method );
   5:         String response = method.getResponseBodyAsString();

View Full Code Here
   1:     public static void main(String[] args) {
   2:         HttpClient client = new HttpClient();
   3:         HttpMethod method = new GetMethod( url );
   4:     
   5:         try {

View Full Code Here

HttpClient

public HttpClient(HttpConnectionManager httpConnectionManager)
Creates an instance of HttpClient with a user specified HTTP connection manager.
Parameters:
httpConnectionManager - The connection manager to use.
Since:
2.0
Usages and Demos :

View More Examples of HttpClient(HttpConnectionManager httpConnectionManager)
   1:     {
   2:         HttpClient client = new HttpClient( connectionManager );
   3:         
   4:         return client;
   5:     }

View Full Code Here
   1:         for( int i = 0; i < 20; i++ ) {
   2:             HttpClient client = new HttpClient(connectionManager);
   3:             Thread thread = new Thread( new PageRetriever(client) );
   4:             retrievers.add( thread );
   5:         }

View Full Code Here
   1:     public static HttpClient getNewClient(int connectTimeout, int soTimeout) {
   2:         HttpClient client = new HttpClient(MANAGER);
   3:         client.setConnectionTimeout(connectTimeout);
   4:         client.setTimeout(soTimeout);
   5:         return client;

View Full Code Here
   1:         httpConnectionManager.setMaxTotalConnections(maxHttpConnections);
   2:         httpClient = new HttpClient(httpConnectionManager);
   3:         URI parsedBaseURL = new URI(baseURL);
   4:         hostConfiguration = new HostConfiguration();
   5:         hostConfiguration.setHost(parsedBaseURL.getHost(), parsedBaseURL.getPort(), parsedBaseURL.getScheme());

View Full Code Here
   1:                 try {
   2:                     HttpClient httpClient = new HttpClient(connectionManager);
   3:                     httpClient.getState().setAuthenticationPreemptive(true);
   4:                     String login = user.getLogin().replaceAll("@", "@@");
   5:                     UsernamePasswordCredentials credentials =

View Full Code Here

HttpClient

public HttpClient(HttpClientParams params)
Creates an instance of HttpClient using the given parameter set.
Parameters:
params - The parameters to use.
Since:
3.0
Usages and Demos :

View More Examples of HttpClient(HttpClientParams params)
   1:     {
   2:         HttpClient client = new HttpClient( connectionManager );
   3:         
   4:         return client;
   5:     }

View Full Code Here
   1:         for( int i = 0; i < 20; i++ ) {
   2:             HttpClient client = new HttpClient(connectionManager);
   3:             Thread thread = new Thread( new PageRetriever(client) );
   4:             retrievers.add( thread );
   5:         }

View Full Code Here
   1:     public static HttpClient getNewClient(int connectTimeout, int soTimeout) {
   2:         HttpClient client = new HttpClient(MANAGER);
   3:         client.setConnectionTimeout(connectTimeout);
   4:         client.setTimeout(soTimeout);
   5:         return client;

View Full Code Here
   1:         httpConnectionManager.setMaxTotalConnections(maxHttpConnections);
   2:         httpClient = new HttpClient(httpConnectionManager);
   3:         URI parsedBaseURL = new URI(baseURL);
   4:         hostConfiguration = new HostConfiguration();
   5:         hostConfiguration.setHost(parsedBaseURL.getHost(), parsedBaseURL.getPort(), parsedBaseURL.getScheme());

View Full Code Here
   1:                 try {
   2:                     HttpClient httpClient = new HttpClient(connectionManager);
   3:                     httpClient.getState().setAuthenticationPreemptive(true);
   4:                     String login = user.getLogin().replaceAll("@", "@@");
   5:                     UsernamePasswordCredentials credentials =

View Full Code Here

HttpClient

public HttpClient(HttpClientParams params,
                  HttpConnectionManager httpConnectionManager)
Creates an instance of HttpClient with a user specified parameter set and HTTP connection manager.
Parameters:
params - The parameters to use.
httpConnectionManager - The connection manager to use.
Since:
3.0
Usages and Demos :

View More Examples of HttpClient(HttpClientParams params,HttpConnectionManager httpConnectionManager)
   1:     public void afterPropertiesSet() throws Exception {
   2:         this.httpClient = new HttpClient(this.httpClientParams, this.manager);
   3:         this.manager.setParams(this.httpConnectionManagerParams);
   4: 
   5:         this.httpConnectionManagerParams.setStaleCheckingEnabled(true);

View Full Code Here

Method Details

executeMethod

public int executeMethod(HostConfiguration hostConfiguration,
                         HttpMethod method)
            throws IOException,
                   HttpException
Executes the given HTTP method using custom host configuration.
Parameters:
hostConfiguration - The host configuration to use. If null, the host configuration returned by getHostConfiguration() will be used.
method - the HTTP method to execute.
Returns:
the method's response code
Throws:
IOException - If an I/O (transport) error occurs. Some transport exceptions can be recovered from.
HttpException - If a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
Since:
2.0
Usages and Demos :

View More Examples of executeMethod(HostConfiguration hostConfiguration,HttpMethod method)
   1: import org.apache.cactus.internal.util.UrlUtil;
   2: import org.apache.commons.httpclient.HostConfiguration;
   3:         ...
   4: import org.apache.commons.httpclient.HttpClient;
   5:         ...
   6: import org.apache.commons.httpclient.HttpState;
   7: import org.apache.commons.httpclient.HttpMethod;
   8:         ...
   9:         client.setState(state);
  10:         client.executeMethod(hostConfiguration, this.method);

View Full Code Here
   1: import org.apache.cactus.util.UrlUtil;
   2: import org.apache.commons.httpclient.HostConfiguration;
   3:         ...
   4: import org.apache.commons.httpclient.HttpClient;
   5:         ...
   6: import org.apache.commons.httpclient.HttpState;
   7: import org.apache.commons.httpclient.HttpMethod;
   8:         ...
   9:         client.setState(state);
  10:         client.executeMethod(hostConfiguration, this.method);

View Full Code Here

executeMethod

public int executeMethod(HostConfiguration hostconfig,
                         HttpMethod method,
                         HttpState state)
            throws IOException,
                   HttpException
Executes the given HTTP method using the given custom host configuration with the given custom HTTP state.
Parameters:
hostconfig - The host configuration to use. If null, the host configuration returned by getHostConfiguration() will be used.
method - the HTTP method to execute.
state - the HTTP state to use when executing the method. If null, the state returned by getState() will be used.
Returns:
the method's response code
Throws:
IOException - If an I/O (transport) error occurs. Some transport exceptions can be recovered from.
HttpException - If a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
Since:
2.0
Usages and Demos :

View More Examples of executeMethod(HostConfiguration hostconfig,HttpMethod method,HttpState state)
   1: 
   2: import org.apache.commons.httpclient.*;
   3: import org.apache.xmlbeans.XmlObject;
   4:         ...
   5:     private static final boolean validateResponses = false;
   6:     private HttpClient sharedHttpClient;
   7:     private HttpState httpState;
   8:         ...
   9: 
  10:     public DaisyHttpClient(HttpClient sharedHttpClient, HostConfiguration sharedHostConfiguration, HttpState httpState, String login) {
  11:         this.sharedHttpClient = sharedHttpClient;
  12:         ...
  13:             try {
  14:                 statusCode = sharedHttpClient.executeMethod(sharedHostConfiguration, method, httpState);

View Full Code Here

executeMethod

public int executeMethod(HttpMethod method)
            throws IOException,
                   HttpException
Executes the given HTTP method.
Parameters:
method - the HTTP method to execute.
Returns:
the method's response code
Throws:
IOException - If an I/O (transport) error occurs. Some transport exceptions can be recovered from.
HttpException - If a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
Usages and Demos :

View More Examples of executeMethod(HttpMethod method)
   1: package com.discursive.jccook.httpclient;
   2: 
   3:         ...
   4: 
   5: import org.apache.commons.httpclient.Cookie;
   6:         ...
   7: import org.apache.commons.httpclient.HttpClient;
   8: import org.apache.commons.httpclient.HttpException;
   9:         ...
  10:         HttpMethod method = new GetMethod( url );
  11:         client.executeMethod( method );

View Full Code Here
   1: import java.io.InputStreamReader;
   2: import org.apache.commons.httpclient.HttpClient;
   3:         ...
   4: import org.apache.commons.httpclient.cookie.CookiePolicy;
   5:         ...
   6: import org.apache.commons.httpclient.methods.GetMethod;
   7: 
   8:         ...
   9:       GetMethod get = new GetMethod("/main/jsps/announcements.jsp");
  10:       client.executeMethod(get);

View Full Code Here
   1: 
   2: import org.apache.commons.httpclient.HttpClient;
   3:         ...
   4: import org.apache.commons.httpclient.HttpException;
   5:         ...
   6: import org.apache.commons.httpclient.methods.HeadMethod;
   7: import org.apache.commons.lang.WordUtils;
   8:         ...
   9:         HttpClient client = new HttpClient();
  10:         client.executeMethod(head);

View Full Code Here
   1: package com.discursive.jccook.httpclient;
   2: 
   3:         ...
   4: 
   5: import org.apache.commons.httpclient.HttpClient;
   6:         ...
   7: import org.apache.commons.httpclient.HttpException;
   8: import org.apache.commons.httpclient.HttpMethod;
   9:         ...
  10:         HttpMethod method = new GetMethod( url );
  11:         client.executeMethod( method );

View Full Code Here
   1: package com.discursive.jccook.httpclient;
   2: 
   3:         ...
   4: 
   5: import org.apache.commons.httpclient.HttpClient;
   6:         ...
   7: import org.apache.commons.httpclient.HttpException;
   8: import org.apache.commons.httpclient.HttpMethod;
   9:         ...
  10:         try {
  11:             client.executeMethod( method );

View Full Code Here

getHost

public String getHost()

Deprecated. use #getHostConfiguration()

Returns the default host.
Returns:
The default host.

getHostConfiguration

public HostConfiguration getHostConfiguration()
Returns the host configuration associated with the HttpClient.
Since:
2.0
Usages and Demos :

View More Examples of getHostConfiguration()
   1: import java.io.InputStreamReader;
   2: import org.apache.commons.httpclient.HttpClient;
   3:         ...
   4: import org.apache.commons.httpclient.cookie.CookiePolicy;
   5:         ...
   6: import org.apache.commons.httpclient.methods.GetMethod;
   7: 
   8:         ...
   9:       HttpClient client = new HttpClient();
  10:       client.getHostConfiguration().setHost("uonline.utah.edu", 80, "http");

View Full Code Here
   1: 
   2: import org.apache.commons.httpclient.HttpClient;
   3:         ...
   4: import org.apache.commons.httpclient.NameValuePair;
   5:         ...
   6: import org.apache.commons.httpclient.methods.PostMethod;
   7: 
   8:         ...
   9:         {
  10:             client.getHostConfiguration().setHost("24.97.85.139");

View Full Code Here
   1: 
   2: import org.apache.commons.httpclient.HttpClient;
   3:         ...
   4: import org.apache.commons.httpclient.NameValuePair;
   5:         ...
   6: import org.apache.commons.httpclient.methods.PostMethod;
   7: 
   8:         ...
   9:         {
  10:             client.getHostConfiguration().setHost("dice.tripleawarclub.org");

View Full Code Here
   1: 
   2: import org.apache.commons.httpclient.HttpClient;
   3:         ...
   4: import org.apache.commons.httpclient.methods.GetMethod;
   5: 
   6:         ...
   7:         Properties props = new Properties();
   8:         HttpClient client = new HttpClient();
   9:         ...
  10:         client.getHostConfiguration().setHost(url.getHost());

View Full Code Here
   1: package org.keyworx.amuse.test.httpclient;
   2: 
   3:         ...
   4: import org.apache.commons.httpclient.HttpClient;
   5:         ...
   6: import org.apache.commons.httpclient.HttpException;
   7: import org.apache.commons.httpclient.HttpMethod;
   8:         ...
   9:             HttpClient client = new HttpClient();
  10:             client.getHostConfiguration().setHost(host, port, "http");

View Full Code Here

getHttpConnectionManager

public HttpConnectionManager getHttpConnectionManager()
Returns the HTTP connection manager associated with the HttpClient.
Since:
2.0
Usages and Demos :

View More Examples of getHttpConnectionManager()
   1: 
   2: import org.apache.commons.httpclient.Cookie;
   3:         ...
   4: import org.apache.commons.httpclient.Header;
   5:         ...
   6: import org.apache.commons.httpclient.HttpClient;
   7: import org.apache.commons.httpclient.HttpConnection;
   8:         ...
   9:             scheme = HttpAuthenticator.selectAuthScheme(headers);
  10:             HttpConnection conn = client.getHttpConnectionManager().getConnection(get.getHostConfiguration());

View Full Code Here
   1: 
   2: import org.apache.commons.httpclient.Cookie;
   3:         ...
   4: import org.apache.commons.httpclient.HttpClient;
   5:         ...
   6: import org.apache.commons.httpclient.HttpState;
   7: import org.apache.commons.httpclient.cookie.CookiePolicy;
   8:         ...
   9:         HttpClient httpclient = new HttpClient();
  10:         httpclient.getHttpConnectionManager().

View Full Code Here
   1: 
   2: import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
   3:         ...
   4: import org.apache.commons.httpclient.HttpClient;
   5:         ...
   6: import org.apache.commons.httpclient.methods.HeadMethod;
   7: import org.apache.commons.httpclient.params.HttpMethodParams;
   8:         ...
   9:             httpClient.getParams().setSoTimeout( 10000 );
  10:             httpClient.getHttpConnectionManager().getParams().setConnectionTimeout( 5000 );

View Full Code Here
   1: package org.apache.commons.httpclient.contrib.benchmark;
   2: 
   3:         ...
   4: import org.apache.commons.cli.PosixParser;
   5: import org.apache.commons.httpclient.HostConfiguration;
   6:         ...
   7: import org.apache.commons.httpclient.HttpClient;
   8: import org.apache.commons.httpclient.HttpMethod;
   9:         ...
  10:         httpclient.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE, false);
  11:         httpclient.getHttpConnectionManager().getParams().setStaleCheckingEnabled(false);

View Full Code Here
   1: 
   2: import org.apache.commons.httpclient.HttpClient;
   3:         ...
   4: import org.apache.commons.httpclient.HttpStatus;
   5:         ...
   6: import org.apache.commons.httpclient.methods.PostMethod;
   7: import org.apache.commons.httpclient.methods.multipart.FilePart;
   8:         ...
   9:                         HttpClient client = new HttpClient();
  10:                         client.getHttpConnectionManager().

View Full Code Here

getParams

public HttpClientParams getParams()
Returns HTTP protocol parameters associated with this HttpClient.
Since:
3.0
Usages and Demos :

View More Examples of getParams()
   1: import java.io.InputStreamReader;
   2: import org.apache.commons.httpclient.HttpClient;
   3:         ...
   4: import org.apache.commons.httpclient.cookie.CookiePolicy;
   5:         ...
   6: import org.apache.commons.httpclient.methods.GetMethod;
   7: 
   8:         ...
   9:       client.getHostConfiguration().setHost("uonline.utah.edu", 80, "http");
  10:       client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);

View Full Code Here
   1: import org.apache.pluto.util.publish.PublishException;
   2: import org.apache.commons.httpclient.HttpClient;
   3:         ...
   4: import org.apache.commons.httpclient.HostConfiguration;
   5:         ...
   6: import org.apache.commons.httpclient.HttpException;
   7: import org.apache.commons.httpclient.methods.GetMethod;
   8:         ...
   9:         client.setHostConfiguration(getHostConfiguration(config));
  10:         client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);

View Full Code Here
   1: 
   2: import org.apache.commons.httpclient.HttpClient;
   3:         ...
   4: import org.apache.commons.httpclient.UsernamePasswordCredentials;
   5:         ...
   6: import org.apache.commons.httpclient.auth.AuthPolicy;
   7: import org.apache.commons.httpclient.auth.AuthScope;
   8:         ...
   9:         authPrefs.add(AuthPolicy.DIGEST);
  10:         client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);

View Full Code Here
   1: 
   2: import org.apache.commons.httpclient.Cookie;
   3:         ...
   4: import org.apache.commons.httpclient.HttpClient;
   5:         ...
   6: import org.apache.commons.httpclient.HttpState;
   7: import org.apache.commons.httpclient.cookie.CookiePolicy;
   8:         ...
   9: 
  10:         httpclient.getParams().setCookiePolicy(CookiePolicy.RFC_2109);

View Full Code Here
   1: 
   2: import org.apache.commons.httpclient.Credentials;
   3:         ...
   4: import org.apache.commons.httpclient.HttpClient;
   5:         ...
   6: import org.apache.commons.httpclient.NTCredentials;
   7: import org.apache.commons.httpclient.UsernamePasswordCredentials;
   8:         ...
   9:         HttpClient client = new HttpClient();
  10:         client.getParams().setParameter(

View Full Code Here

getPort

public int getPort()

Deprecated. use #getHostConfiguration()

Returns the default port.
Returns:
The default port.

getState

public HttpState getState()
Returns HTTP state associated with the HttpClient.
Returns:
the shared client state
Usages and Demos :

View More Examples of getState()
   1: package com.discursive.jccook.httpclient;
   2: 
   3:         ...
   4: 
   5: import org.apache.commons.httpclient.Cookie;
   6:         ...
   7: import org.apache.commons.httpclient.HttpClient;
   8: import org.apache.commons.httpclient.HttpException;
   9:         ...
  10:         Cookie cookie = new Cookie(".discursive.com", "test_cookie", "hello", "/", null, false );
  11:         client.getState().addCookie( cookie );

View Full Code Here
   1: package com.discursive.jccook.httpclient;
   2: 
   3:         ...
   4: 
   5: import org.apache.commons.httpclient.Credentials;
   6:         ...
   7: import org.apache.commons.httpclient.HttpClient;
   8: import org.apache.commons.httpclient.HttpException;
   9:         ...
  10:             new NTCredentials( "testuser", "crazypass", "tobrien.discursive.com", "DOMAIN" );
  11:         client.getState().setCredentials( null, null, credentials );

View Full Code Here
   1: 
   2: import org.apache.commons.httpclient.HttpClient;
   3:         ...
   4: import org.apache.commons.httpclient.UsernamePasswordCredentials;
   5:         ...
   6: import org.apache.commons.httpclient.auth.AuthScope;
   7: import org.apache.commons.httpclient.methods.GetMethod;
   8:         ...
   9: 
  10:         client.getState().setCredentials(

View Full Code Here
   1: 
   2: import org.apache.commons.httpclient.HttpClient;
   3:         ...
   4: import org.apache.commons.httpclient.UsernamePasswordCredentials;
   5:         ...
   6: import org.apache.commons.httpclient.auth.AuthPolicy;
   7: import org.apache.commons.httpclient.auth.AuthScope;
   8:         ...
   9:         HttpClient client = new HttpClient();
  10:         client.getState().setCredentials(

View Full Code Here
   1: package org.apache.commons.httpclient.contrib.auth;
   2: 
   3:         ...
   4: 
   5: import org.apache.commons.httpclient.Credentials;
   6:         ...
   7: import org.apache.commons.httpclient.HttpClient;
   8: import org.apache.commons.httpclient.auth.AuthPolicy;
   9:         ...
  10:         Credentials use_jaas_creds = new Credentials() {};
  11:         client.getState().setCredentials(

View Full Code Here

isStrictMode

public boolean isStrictMode()

Deprecated. Use HttpClientParams.getParameter(String) to exercise a more granular control over HTTP protocol strictness.

Returns the value of the strict mode flag.
Returns:
true if strict mode is enabled, false otherwise

setConnectionTimeout

public void setConnectionTimeout(int newTimeoutInMilliseconds)

Deprecated. Use HttpConnectionManagerParams.setConnectionTimeout(int), HttpConnectionManager.getParams().

Sets the timeout until a connection is etablished. A value of zero means the timeout is not used. The default value is zero.
Parameters:
newTimeoutInMilliseconds - Timeout in milliseconds.
Usages and Demos :

View More Examples of setConnectionTimeout(int newTimeoutInMilliseconds)
   1: package org.keyworx.amuse.test.httpclient;
   2: 
   3:         ...
   4: import org.apache.commons.httpclient.HttpClient;
   5:         ...
   6: import org.apache.commons.httpclient.HttpException;
   7: import org.apache.commons.httpclient.HttpMethod;
   8:         ...
   9:             client.getState().setCookiePolicy(CookiePolicy.COMPATIBILITY);
  10:             client.setConnectionTimeout(15000);

View Full Code Here
   1: package org.keyworx.amuse.test.httpclient;
   2: 
   3:         ...
   4: import org.apache.commons.httpclient.HttpClient;
   5:         ...
   6: import org.apache.commons.httpclient.HttpException;
   7: import org.apache.commons.httpclient.HttpMethod;
   8:         ...
   9:             client.getState().setCookiePolicy(CookiePolicy.COMPATIBILITY);
  10:             client.setConnectionTimeout(15000);

View Full Code Here
   1: package org.keyworx.amuse.test.httpclient;
   2: 
   3:         ...
   4: import nl.justobjects.jox.parser.JXBuilder;
   5: import org.apache.commons.httpclient.HttpClient;
   6:         ...
   7: import org.apache.commons.httpclient.HttpException;
   8: import org.apache.commons.httpclient.cookie.CookiePolicy;
   9:         ...
  10:         client.getState().setCookiePolicy(CookiePolicy.COMPATIBILITY);
  11:         client.setConnectionTimeout(15000);

View Full Code Here
   1: 
   2: import org.apache.commons.httpclient.Header;
   3:         ...
   4: import org.apache.commons.httpclient.HostConfiguration;
   5:         ...
   6: import org.apache.commons.httpclient.HttpClient;
   7: import org.apache.commons.httpclient.HttpConnectionManager;
   8:         ...
   9:         HttpClient client = new HttpClient(MANAGER);
  10:         client.setConnectionTimeout(connectTimeout);

View Full Code Here
   1: 
   2: import org.apache.commons.httpclient.HttpClient;
   3:         ...
   4: import org.apache.commons.httpclient.HttpMethod;
   5:         ...
   6: import org.apache.commons.httpclient.StatusLine;
   7: import org.apache.commons.httpclient.methods.GetMethod;
   8:         ...
   9:     
  10:                 client.setConnectionTimeout(5000);

View Full Code Here

setHostConfiguration

public void setHostConfiguration(HostConfiguration hostConfiguration)
Assigns the host configuration to use with the HttpClient.
Parameters:
hostConfiguration - The host configuration to set
Since:
2.0
Usages and Demos :

View More Examples of setHostConfiguration(HostConfiguration hostConfiguration)
   1: 
   2: import org.apache.commons.httpclient.HostConfiguration;
   3:         ...
   4: import org.apache.commons.httpclient.HttpClient;
   5:         ...
   6: import org.apache.commons.httpclient.HttpException;
   7: import org.apache.commons.httpclient.methods.PostMethod;
   8:         ...
   9:             HttpClient client = new HttpClient();
  10:             client.setHostConfiguration(config);

View Full Code Here
   1: import org.apache.pluto.util.publish.PublishException;
   2: import org.apache.commons.httpclient.HttpClient;
   3:         ...
   4: import org.apache.commons.httpclient.HostConfiguration;
   5:         ...
   6: import org.apache.commons.httpclient.HttpException;
   7: import org.apache.commons.httpclient.methods.GetMethod;
   8:         ...
   9:         HttpClient client = new HttpClient();
  10:         client.setHostConfiguration(getHostConfiguration(config));

View Full Code Here
   1: 
   2: import org.apache.commons.httpclient.HostConfiguration;
   3:         ...
   4: import org.apache.commons.httpclient.HttpClient;
   5:         ...
   6: import org.apache.commons.httpclient.HttpException;
   7: import org.apache.commons.httpclient.methods.GetMethod;
   8:         ...
   9:             HttpClient client = new HttpClient();
  10:             client.setHostConfiguration(config);

View Full Code Here
   1: 
   2: import org.apache.commons.httpclient.HostConfiguration;
   3:         ...
   4: import org.apache.commons.httpclient.HttpClient;
   5:         ...
   6: import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
   7: import org.apache.commons.httpclient.UsernamePasswordCredentials;
   8:         ...
   9: 
  10:             client.setHostConfiguration(config);

View Full Code Here
   1: 
   2: import org.apache.commons.httpclient.HostConfiguration;
   3:         ...
   4: import org.apache.commons.httpclient.HttpClient;
   5:         ...
   6: import org.apache.commons.httpclient.HttpMethod;
   7: import org.apache.commons.httpclient.HttpState;
   8:         ...
   9:         hostConfiguration.setHost(host, port);
  10:         httpClient.setHostConfiguration(hostConfiguration);

View Full Code Here

setHttpConnectionFactoryTimeout

public void setHttpConnectionFactoryTimeout(long timeout)

Deprecated. Use HttpClientParams.setConnectionManagerTimeout(long), getParams()

Sets the timeout in milliseconds used when retrieving an HTTP connection from the HTTP connection manager.
Parameters:
timeout - the timeout in milliseconds

setHttpConnectionManager

public void setHttpConnectionManager(HttpConnectionManager httpConnectionManager)
Assigns the HTTP connection manager to use with the HttpClient.
Parameters:
httpConnectionManager - The HTTP connection manager to set
Since:
2.0

setParams

public void setParams(HttpClientParams params)
Assigns HTTP protocol parameters for this HttpClient.
Since:
3.0

setState

public void setState(HttpState state)
Assigns HTTP state for the HttpClient.
Parameters:
state - the new HTTP state for the client
See Also:
getState()
Usages and Demos :

View More Examples of setState(HttpState state)
   1: 
   2: import org.apache.commons.httpclient.Cookie;
   3:         ...
   4: import org.apache.commons.httpclient.Header;
   5:         ...
   6: import org.apache.commons.httpclient.HttpClient;
   7: import org.apache.commons.httpclient.HttpConnection;
   8:         ...
   9:             client = new HttpClient();
  10:             client.setState(initialState);

View Full Code Here
   1: 
   2: import org.apache.commons.httpclient.Cookie;
   3:         ...
   4: import org.apache.commons.httpclient.HttpClient;
   5:         ...
   6: import org.apache.commons.httpclient.HttpState;
   7: import org.apache.commons.httpclient.cookie.CookiePolicy;
   8:         ...
   9:             getParams().setConnectionTimeout(30000);
  10:         httpclient.setState(initialState);

View Full Code Here
   1: 
   2: import org.apache.commons.httpclient.Credentials;
   3:         ...
   4: import org.apache.commons.httpclient.HttpClient;
   5:         ...
   6: import org.apache.commons.httpclient.HttpState;
   7: import org.apache.commons.httpclient.HttpStatus;
   8:         ...
   9:         if (httpState != null)
  10:             httpclient.setState(httpState);

View Full Code Here
   1: 
   2: import org.apache.commons.httpclient.HostConfiguration;
   3:         ...
   4: import org.apache.commons.httpclient.HttpClient;
   5:         ...
   6: import org.apache.commons.httpclient.HttpMethod;
   7: import org.apache.commons.httpclient.HttpState;
   8:         ...
   9:         state.setCredentials(null, null, new UsernamePasswordCredentials(username, password));
  10:         httpClient.setState(state);

View Full Code Here
   1: import org.apache.cactus.internal.util.UrlUtil;
   2: import org.apache.commons.httpclient.HostConfiguration;
   3:         ...
   4: import org.apache.commons.httpclient.HttpClient;
   5:         ...
   6: import org.apache.commons.httpclient.HttpState;
   7: import org.apache.commons.httpclient.HttpMethod;
   8:         ...
   9:             Protocol.getProtocol(url.getProtocol()));
  10:         client.setState(state);

View Full Code Here

setStrictMode

public void setStrictMode(boolean strictMode)

Deprecated. Use HttpClientParams.setParameter(String,Object) to exercise a more granular control over HTTP protocol strictness.

Defines how strictly the method follows the HTTP protocol specification (see RFC 2616 and other relevant RFCs). In the strict mode the method precisely implements the requirements of the specification, whereas in non-strict mode it attempts to mimic the exact behaviour of commonly used HTTP agents, which many HTTP servers expect.
Parameters:
strictMode - true for strict mode, false otherwise

setTimeout

public void setTimeout(int newTimeoutInMilliseconds)

Deprecated. Use HttpConnectionManagerParams.setSoTimeout(int), HttpConnectionManager.getParams().

Sets the socket timeout (SO_TIMEOUT) in milliseconds which is the timeout for waiting for data. A timeout value of zero is interpreted as an infinite timeout.
Parameters:
newTimeoutInMilliseconds - Timeout in milliseconds
Usages and Demos :

View More Examples of setTimeout(int newTimeoutInMilliseconds)
   1: 
   2: import org.apache.commons.httpclient.Header;
   3:         ...
   4: import org.apache.commons.httpclient.HostConfiguration;
   5:         ...
   6: import org.apache.commons.httpclient.HttpClient;
   7: import org.apache.commons.httpclient.HttpConnectionManager;
   8:         ...
   9:         client.setConnectionTimeout(connectTimeout);
  10:         client.setTimeout(soTimeout);

View Full Code Here