org.apache.commons.httpclient

Interface HttpMethod

Known Implementing Classes:
ConnectMethod, DeleteMethod, EntityEnclosingMethod, ExpectContinueMethod, GetMethod, HeadMethod, HttpMethodBase, MultipartPostMethod, OptionsMethod, PostMethod, PutMethod, TraceMethod

public interface HttpMethod

HttpMethod interface represents a request to be sent via a HTTP connection and a corresponding response.
Since:
1.0

Method Summary

void
abort()
Aborts the execution of the HTTP method.
void
addRequestHeader(String headerName, String headerValue)
Adds the specified request header, not overwriting any previous value.
void
addRequestHeader(Header header)
Adds the specified request header, not overwriting any previous value.
void
addResponseFooter(Header footer)
Add a footer to this method's response.
int
execute(HttpState state, HttpConnection connection)
Executes this method using the specified HttpConnection and HttpState.
boolean
getDoAuthentication()
Returns true if the HTTP method should automatically handle HTTP authentication challenges (status code 401, etc.), false otherwise
boolean
getFollowRedirects()
Returns true if the HTTP method should automatically follow HTTP redirects (status code 302, etc.), false otherwise.
AuthState
getHostAuthState()
Returns the target host authentication state
HostConfiguration
getHostConfiguration()
Deprecated. no longer applicable
String
getName()
Obtains the name of the HTTP method as used in the HTTP request line, for example "GET" or "POST".
HttpMethodParams
getParams()
Returns HTTP protocol parameters associated with this method.
String
getPath()
Returns the path of the HTTP method.
AuthState
getProxyAuthState()
Returns the proxy authentication state
String
getQueryString()
Returns the query string of this HTTP method.
Header
getRequestHeader(String headerName)
Gets the request header with the given name.
Header[]
getRequestHeaders()
Returns the current request headers for this HTTP method.
Header[]
getRequestHeaders(String headerName)
Returns the request headers with the given name.
byte[]
getResponseBody()
Returns the response body of the HTTP method, if any, as an array of bytes.
InputStream
getResponseBodyAsStream()
Returns the response body of the HTTP method, if any, as an InputStream.
String
getResponseBodyAsString()
Returns the response body of the HTTP method, if any, as a String.
Header
getResponseFooter(String footerName)
Return the specified response footer.
Header[]
getResponseFooters()
Returns the response footers from the most recent execution of this request.
Header
getResponseHeader(String headerName)
Returns the specified response header.
Header[]
getResponseHeaders()
Returns the response headers from the most recent execution of this request.
Header[]
getResponseHeaders(String headerName)
Returns the response headers with the given name.
int
getStatusCode()
Returns the status code associated with the latest response.
StatusLine
getStatusLine()
Returns the Status-Line from the most recent response for this method, or null if the method has not been executed.
String
getStatusText()
Returns the status text (or "reason phrase") associated with the latest response.
URI
getURI()
Returns the URI for this method.
boolean
hasBeenUsed()
Returns true if the HTTP method has been already executed, but not recycled.
boolean
isRequestSent()
Returns true if the HTTP has been transmitted to the target server in its entirety, false otherwise.
boolean
isStrictMode()
Deprecated. Use HttpParams.setParameter(String,Object) to exercise a more granular control over HTTP protocol strictness.
void
recycle()
Deprecated. no longer supported and will be removed in the future version of HttpClient
void
releaseConnection()
Releases the connection being used by this HTTP method.
void
removeRequestHeader(String headerName)
Removes all request headers with the given name.
void
removeRequestHeader(Header header)
Removes the given request header.
void
setDoAuthentication(boolean doAuthentication)
Sets whether or not the HTTP method should automatically handle HTTP authentication challenges (status code 401, etc.)
void
setFollowRedirects(boolean followRedirects)
Sets whether or not the HTTP method should automatically follow HTTP redirects (status code 302, etc.)
void
setParams(HttpMethodParams params)
Assigns HTTP protocol parameters for this method.
void
setPath(String path)
Sets the path of the HTTP method.
void
setQueryString(String queryString)
Sets the query string of the HTTP method.
void
setQueryString(NameValuePair[] params)
Sets the query string of this HTTP method.
void
setRequestHeader(String headerName, String headerValue)
Sets the specified request header, overwriting any previous value.
void
setRequestHeader(Header header)
Sets the specified request header, overwriting any previous value.
void
setStrictMode(boolean strictMode)
Deprecated. Use HttpParams.setParameter(String,Object) to exercise a more granular control over HTTP protocol strictness.
void
setURI(URI uri)
Sets the URI for this method.
boolean
validate()
Returns true the method is ready to execute, false otherwise.

Method Details

abort

public void abort()
Aborts the execution of the HTTP method.
Since:
3.0

addRequestHeader

public void addRequestHeader(String headerName,
                             String headerValue)
Adds the specified request header, not overwriting any previous value. If the same header is added multiple times, perhaps with different values, multiple instances of that header will be sent in the HTTP request. Note that header-name matching is case insensitive.
Parameters:
headerName - the header's name
headerValue - the header's value
Usages and Demos :

View More Examples of addRequestHeader(String headerName,String headerValue)
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.HttpVersion;
   4:         ...
   5:         
   6:         HttpMethod method = null;
   7:         if (cmd.hasOption('p')) {
   8:         ...
   9:         if (!keepAlive) {
  10:             method.addRequestHeader("Connection", "close");
  11:         }

View Full Code Here
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.methods.GetMethod;
   4:         ...
   5:                 HttpClient client = HttpClientManager.getNewClient();
   6:                 HttpMethod get = new GetMethod(connectTo);
   7:         ...
   8:                 get.addRequestHeader("Cache-Control", "no-cache");
   9:         ...
  10:                 get.addRequestHeader("User-Agent", CommonUtils.getHttpServer());

View Full Code Here
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.methods.GetMethod;
   4:         ...
   5:         throws Exception {
   6:         HttpMethod get = null;
   7:         try {
   8:         ...
   9:             LOG.trace("Getting update file via direct http: " + address);
  10:             get.addRequestHeader("Cache-Control", "no-cache");
  11:         ...
  12:             get.addRequestHeader("User-Agent", CommonUtils.getHttpServer());

View Full Code Here
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.methods.GetMethod;
   4:         ...
   5: 
   6:     private HttpMethod method;
   7: 
   8:         ...
   9:         method.setFollowRedirects(false);
  10:         method.addRequestHeader("Cache-Control", "no-cache");
  11:         method.addRequestHeader( HTTPHeaderNames.USER_AGENT,

View Full Code Here
   1: 
   2:         HttpMethod method;
   3: 
   4:         ...
   5:         if ( hsr.getMethod().equals(METHOD_GET)) {
   6:             HttpMethod getMethod = new GetMethod(proxyForwardHost +
   7:                     proxyForwardUri + (hsr.getQueryString() != null ? ("?" + hsr.getQueryString()) : "")
   8:         ...
   9:             if (hn.equalsIgnoreCase("host")) {
  10:                 method.addRequestHeader("Host", proxyForwardHost);
  11:                 continue;
  12:         ...
  13:                 String hv = (String)hvals.nextElement();
  14:                 method.addRequestHeader(hn, hv);

View Full Code Here

addRequestHeader

public void addRequestHeader(Header header)
Adds the specified request header, not overwriting any previous value. If the same header is added multiple times, perhaps with different values, multiple instances of that header will be sent in the HTTP request. Note that header-name matching is case insensitive.
Parameters:
header - the header
Usages and Demos :

View More Examples of addRequestHeader(Header header)
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.HttpStatus;
   4:         ...
   5:     public static void executeMethodRedirecting(HttpClient client,
   6:                                                 HttpMethod methid)
   7:       throws IOException, HttpException {
   8:         ...
   9:     public static void executeMethodRedirecting(HttpClient client,
  10:                                                 HttpMethod methid,
  11:                                                 int redirects)
  12:         ...
  13:                     if(!requestHeaders[j].getName().equals("Host"))
  14:                         methid.addRequestHeader(requestHeaders[j]);

View Full Code Here
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.methods.GetMethod;
   4:         ...
   5:                 HttpClient client = HttpClientManager.getNewClient();
   6:                 HttpMethod get = new GetMethod(connectTo);
   7:                 get.addRequestHeader("Cache-Control", "no-cache");
   8:         ...
   9:                 get.addRequestHeader("User-Agent", CommonUtils.getHttpServer());
  10:                 get.addRequestHeader(HTTPHeaderName.CONNECTION.httpStringValue(),
  11:                                      "close");

View Full Code Here
   1: import org.apache.commons.httpclient.HttpConnection;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.HttpState;
   4:         ...
   5:     private static boolean doAuthenticateDefault(
   6:         HttpMethod method, 
   7:         HttpConnection conn,
   8:         ...
   9:             Header header = new Header(s, auth, true);
  10:             method.addRequestHeader(header);
  11:             return true;
  12:         ...
  13:     public static boolean authenticateDefault(
  14:         HttpMethod method, 

View Full Code Here

addResponseFooter

public void addResponseFooter(Header footer)
Add a footer to this method's response.

Note: This method is for internal use only and should not be called by external clients.

Parameters:
footer - the footer to add
Since:
2.0

execute

public int execute(HttpState state,
                   HttpConnection connection)
            throws HttpException,
                   IOException
Executes this method using the specified HttpConnection and HttpState.
Parameters:
state - the state information to associate with this method
connection - the connection used to execute this HTTP method
Returns:
the integer status code if one was obtained, or -1
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.

getDoAuthentication

public boolean getDoAuthentication()
Returns true if the HTTP method should automatically handle HTTP authentication challenges (status code 401, etc.), false otherwise
Returns:
true if authentication challenges will be processed automatically, false otherwise.
Since:
2.0

getFollowRedirects

public boolean getFollowRedirects()
Returns true if the HTTP method should automatically follow HTTP redirects (status code 302, etc.), false otherwise.
Returns:
true if the method will automatically follow HTTP redirects, false otherwise

getHostAuthState

public AuthState getHostAuthState()
Returns the target host authentication state
Returns:
host authentication state
Since:
3.0
Usages and Demos :

View More Examples of getHostAuthState()
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.NameValuePair;
   4:         ...
   5:     
   6:     protected byte[] doPreemptiveAuthentication(HttpClient client,HttpMethod method, RenderRequest request, RenderResponse response)
   7:     {
   8:         ...
   9:             method.setDoAuthentication(true);
  10:             method.getHostAuthState().setPreemptive();
  11:             client.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(userName, password));
  12:         ...
  13: 
  14:     protected boolean doRequestedAuthentication(HttpClient client,HttpMethod method, RenderRequest request, RenderResponse response)

View Full Code Here

getHostConfiguration

public HostConfiguration getHostConfiguration()

Deprecated. no longer applicable

Gets the host configuration for this method. The configuration specifies the server, port, protocol, and proxy server via which this method will send its HTTP request.
Returns:
the HostConfiguration or null if none is set

getName

public String getName()
Obtains the name of the HTTP method as used in the HTTP request line, for example "GET" or "POST".
Returns:
the name of this method

getParams

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

View More Examples of getParams()
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: 
   4:         ...
   5:             final HostConfiguration hostconf,
   6:             final HttpMethod method, 
   7:             int count,
   8:         ...
   9:                     System.out.println(">> " + method.getName() + " " + 
  10:                             method.getURI() + " " + method.getParams().getVersion());
  11:                     Header[] headers = method.getRequestHeaders();

View Full Code Here
   1: import org.apache.commons.httpclient.Credentials;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.UsernamePasswordCredentials;
   4:         ...
   5: 
   6:     public String authenticate(Credentials credentials, HttpMethod method) throws AuthenticationException {
   7: 
   8:         ...
   9:         LOG.trace("enter BasicScheme.authenticate(Credentials, HttpMethod)");
  10: 
  11:         ...
  12:             usernamepassword, 
  13:             method.getParams().getCredentialCharset());

View Full Code Here
   1: import org.apache.commons.httpclient.HttpConnection;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.HttpState;
   4:         ...
   5:     private static boolean doAuthenticateDefault(
   6:         HttpMethod method, 
   7:         HttpConnection conn,
   8:         ...
   9:             (UsernamePasswordCredentials) credentials,
  10:             method.getParams().getCredentialCharset());
  11:         if (auth != null) {
  12:         ...
  13:     public static boolean authenticateDefault(
  14:         HttpMethod method, 

View Full Code Here

getPath

public String getPath()
Returns the path of the HTTP method. Calling this method after the request has been executed will return the actual path, following any redirects automatically handled by this HTTP method.
Returns:
the path of the HTTP method, in URL encoded form

getProxyAuthState

public AuthState getProxyAuthState()
Returns the proxy authentication state
Returns:
host authentication state
Since:
3.0

getQueryString

public String getQueryString()
Returns the query string of this HTTP method.
Returns:
the query string in URL encoded form, without a leading '?'.
Usages and Demos :

View More Examples of getQueryString()
   1: import org.apache.commons.httpclient.HttpClientError;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.NameValuePair;
   4:         ...
   5: 
   6:     public String authenticate(Credentials credentials, HttpMethod method)
   7:     throws AuthenticationException {
   8:         ...
   9: 
  10:         LOG.trace("enter DigestScheme.authenticate(Credentials, HttpMethod)");
  11: 
  12:         ...
  13:         StringBuffer buffer = new StringBuffer(method.getPath());
  14:         String query = method.getQueryString();

View Full Code Here

getRequestHeader

public Header getRequestHeader(String headerName)
Gets the request header with the given name. If there are multiple headers with the same name, there values will be combined with the ',' separator as specified by RFC2616. Note that header-name matching is case insensitive.
Parameters:
headerName - the header name
Returns:
the header

getRequestHeaders

public Header[] getRequestHeaders()
Returns the current request headers for this HTTP method. The returned headers will be in the same order that they were added with addRequestHeader. If there are multiple request headers with the same name (e.g. Cookie), they will be returned as multiple entries in the array.
Returns:
an array containing all of the request headers

getRequestHeaders

public Header[] getRequestHeaders(String headerName)
Returns the request headers with the given name. Note that header-name matching is case insensitive.
Parameters:
headerName - the name of the headers to be returned.
Returns:
an array of zero or more headers
Since:
3.0

getResponseBody

public byte[] getResponseBody()
            throws IOException
Returns the response body of the HTTP method, if any, as an array of bytes. If the method has not yet been executed or the response has no body, null is returned. Note that this method does not propagate I/O exceptions. If an error occurs while reading the body, null will be returned.
Returns:
The response body, or null if the body is not available.
Throws:
IOException - if an I/O (transport) problem occurs
Usages and Demos :

View More Examples of getResponseBody()
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.methods.GetMethod;
   4:         ...
   5:         throws Exception {
   6:         HttpMethod get = null;
   7:         try {
   8:         ...
   9:             HttpClientManager.getNewClient().executeMethod(get);
  10:             return get.getResponseBody();
  11:         } finally {

View Full Code Here
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.HttpStatus;
   4:         ...
   5:         HttpClient client = new HttpClient();
   6:         HttpMethod method = new GetMethod(wikiPageURL + pageName);
   7:         int status = client.executeMethod(method);
   8:         ...
   9:             throw new Exception("Problem retrieving wiki page " + pageName + " : " + method.getStatusCode() + " : " + HttpStatus.getStatusText(method.getStatusCode()));
  10:         return method.getResponseBody();
  11:     }
  12:         ...
  13:                             HttpClient client = new HttpClient();
  14:                             HttpMethod method = new GetMethod(src);

View Full Code Here

getResponseBodyAsStream

public InputStream getResponseBodyAsStream()
            throws IOException
Returns the response body of the HTTP method, if any, as an InputStream. If the response had no body or the method has not yet been executed, null is returned. Additionally, null may be returned if releaseConnection() has been called or if this method was called previously and the resulting stream was closed.
Returns:
The response body, or null if it is not available
Throws:
IOException - if an I/O (transport) problem occurs
Usages and Demos :

View More Examples of getResponseBodyAsStream()
   1: 
   2:     public XmlObject executeMethod(HttpMethod method, Class xmlObjectResponseClass, boolean releaseConnection) throws RepositoryException {
   3:         try {
   4:         ...
   5:                     try {
   6:                         parseResult = (XmlObject)parseMethod.invoke(null, method.getResponseBodyAsStream());
   7:                         if (validateResponses)
   8:         ...
   9: 
  10:     public static String getContentType(HttpMethod method) throws RepositoryException {
  11:         String contentType = null;
  12:         ...
  13: 
  14:     public void handleNotOkResponse(HttpMethod method) throws RepositoryException {

View Full Code Here

getResponseBodyAsString

public String getResponseBodyAsString()
            throws IOException
Returns the response body of the HTTP method, if any, as a String. If response body is not available or cannot be read, null is returned. The raw bytes in the body are converted to a String using the character encoding specified in the response's Content-Type header, or ISO-8859-1 if the response did not specify a character set.

Note that this method does not propagate I/O exceptions. If an error occurs while reading the body, null will be returned.

Returns:
The response body converted to a String, or null if the body is not available.
Throws:
IOException - if an I/O (transport) problem occurs
Usages and Demos :

View More Examples of getResponseBodyAsString()
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.methods.GetMethod;
   4:         ...
   5:         throws IOException, HttpException {
   6:         HttpMethod method = new GetMethod( url );
   7:         client.executeMethod( method );
   8:         ...
   9:         String response = method.getResponseBodyAsString();
  10:         System.out.println( response );

View Full Code Here
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.methods.GetMethod;
   4:         ...
   5:         HttpClient client = new HttpClient();
   6:         HttpMethod method = new GetMethod( url );
   7:         client.executeMethod( method );
   8:         ...
   9:         String response = method.getResponseBodyAsString();
  10:         System.out.println( response );

View Full Code Here
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.methods.GetMethod;
   4:         ...
   5:         HttpClient client = new HttpClient();
   6:         HttpMethod method = new GetMethod( url );
   7:     
   8:         ...
   9:             client.executeMethod( method );
  10:             String response = method.getResponseBodyAsString();

View Full Code Here
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.NTCredentials;
   4:         ...
   5: 
   6:         HttpMethod method = new GetMethod( url );
   7:     
   8:         ...
   9:         client.executeMethod( method );
  10:         String response = method.getResponseBodyAsString();

View Full Code Here
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory;
   4:         ...
   5:         
   6:         HttpMethod method = new GetMethod( url );
   7:         client.executeMethod( method );
   8:         ...
   9:         String response = method.getResponseBodyAsString();
  10:         System.out.println( response );

View Full Code Here

getResponseFooter

public Header getResponseFooter(String footerName)
Return the specified response footer. Note that footer-name matching is case insensitive.
Parameters:
footerName - The name of the footer.
Returns:
The response footer.

getResponseFooters

public Header[] getResponseFooters()
Returns the response footers from the most recent execution of this request.
Returns:
an array containing the response footers in the order that they appeared in the response. If the response had no footers, an empty array will be returned.

getResponseHeader

public Header getResponseHeader(String headerName)
Returns the specified response header. Note that header-name matching is case insensitive.
Parameters:
headerName - The name of the header to be returned.
Returns:
The specified response header. If the repsonse contained multiple instances of the header, its values will be combined using the ',' separator as specified by RFC2616.
Usages and Demos :

View More Examples of getResponseHeader(String headerName)
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.HttpStatus;
   4:         ...
   5:         HttpClient client = new HttpClient();
   6:         HttpMethod method = new GetMethod(wikiPageURL + pageName);
   7:         int status = client.executeMethod(method);
   8:         ...
   9:                             HttpClient client = new HttpClient();
  10:                             HttpMethod method = new GetMethod(src);
  11:                             int status = client.executeMethod(method);
  12:         ...
  13:                             if (status >= 300 && status < 400) {
  14:                                 method = new GetMethod(method.getResponseHeader("location").getValue());

View Full Code Here

getResponseHeaders

public Header[] getResponseHeaders()
Returns the response headers from the most recent execution of this request.
Returns:
A newly-created array containing all of the response headers, in the order in which they appeared in the response.
Usages and Demos :

View More Examples of getResponseHeaders()
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.HttpMethodBase;
   4:         ...
   5:      
   6:     private HttpClient setupConnection(URL u, HttpMethodBase httpMethod, HTTPSampleResult res) throws IOException {
   7: 
   8:         ...
   9: 
  10:         HttpMethodParams params = httpMethod.getParams();
  11:         params.setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
  12:         ...
  13:         StringBuffer headerBuf = new StringBuffer();
  14:         org.apache.commons.httpclient.Header rh[] = method.getResponseHeaders();

View Full Code Here

getResponseHeaders

public Header[] getResponseHeaders(String headerName)
Returns the response headers with the given name. Note that header-name matching is case insensitive.
Parameters:
headerName - the name of the headers to be returned.
Returns:
an array of zero or more headers
Since:
3.0

getStatusCode

public int getStatusCode()
Returns the status code associated with the latest response.
Returns:
The status code from the most recent execution of this method. If the method has not yet been executed, the result is undefined.
Usages and Demos :

View More Examples of getStatusCode()
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.HttpStatus;
   4:         ...
   5:     public static void executeMethodRedirecting(HttpClient client,
   6:                                                 HttpMethod methid)
   7:       throws IOException, HttpException {
   8:         ...
   9:     public static void executeMethodRedirecting(HttpClient client,
  10:                                                 HttpMethod methid,
  11:                                                 int redirects)
  12:         ...
  13:             client.executeMethod(methid);
  14:             switch(methid.getStatusCode()) {

View Full Code Here
   1: 
   2:     public XmlObject executeMethod(HttpMethod method, Class xmlObjectResponseClass, boolean releaseConnection) throws RepositoryException {
   3:         try {
   4:         ...
   5: 
   6:     public static String getContentType(HttpMethod method) throws RepositoryException {
   7:         String contentType = null;
   8:         ...
   9: 
  10:     public void handleNotOkResponse(HttpMethod method) throws RepositoryException {
  11:         if ("text/xml".equals(getContentType(method))) {
  12:         ...
  13:         } else {
  14:             if (method.getStatusCode() == 401) {

View Full Code Here
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.methods.HeadMethod;
   4:         ...
   5:         client.getParams().setParameter(HttpMethodParams.USER_AGENT, userAgent);
   6:         HttpMethod httpMethod;
   7:         if (isGetContents) {
   8:         ...
   9: 
  10:             responseCode = httpMethod.getStatusCode();
  11:             serverDate = DateUtil.parseDate(httpMethod

View Full Code Here
   1: 
   2:         HttpMethod method;
   3: 
   4:         ...
   5:         if ( hsr.getMethod().equals(METHOD_GET)) {
   6:             HttpMethod getMethod = new GetMethod(proxyForwardHost +
   7:                     proxyForwardUri + (hsr.getQueryString() != null ? ("?" + hsr.getQueryString()) : "")
   8:         ...
   9: 
  10:         sres.setStatus(method.getStatusCode());
  11: 
  12:         ...
  13: 
  14:             switch (method.getStatusCode()) {

View Full Code Here
   1: 
   2:         HttpMethod method;
   3: 
   4:         ...
   5:         if ( hsr.getMethod().equals(METHOD_GET)) {
   6:             HttpMethod getMethod = new GetMethod(proxyForwardHost +
   7:                     proxyForwardUri + (hsr.getQueryString() != null ? ("?" + hsr.getQueryString()) : "")
   8:         ...
   9: 
  10:         sres.setStatus(method.getStatusCode());
  11: 
  12:         ...
  13: 
  14:             switch (method.getStatusCode()) {

View Full Code Here

getStatusLine

public StatusLine getStatusLine()
Returns the Status-Line from the most recent response for this method, or null if the method has not been executed.
Returns:
the status line, or null if the method has not been executed
Since:
2.0
Usages and Demos :

View More Examples of getStatusLine()
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.StatusLine;
   4:         ...
   5:     
   6:                 HttpMethod method = new GetMethod(url);
   7:                 method.setQueryString("digitalAssetId=" + digitalAssetId);
   8:         ...
   9:                 client.executeMethod(method);
  10:                 StatusLine status = method.getStatusLine();
  11:                 if (status != null && status.getStatusCode() == 200) {

View Full Code Here

getStatusText

public String getStatusText()
Returns the status text (or "reason phrase") associated with the latest response.
Returns:
The status text from the most recent execution of this method. If the method has not yet been executed, the result is undefined.

getURI

public URI getURI()
            throws URIException
Returns the URI for this method. The URI will be absolute if the host configuration has been set and relative otherwise.
Returns:
the URI for this method
Throws:
URIException - if a URI cannot be constructed
Usages and Demos :

View More Examples of getURI()
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: 
   4:         ...
   5:             final HostConfiguration hostconf,
   6:             final HttpMethod method, 
   7:             int count,
   8:         ...
   9:                     System.out.println(">> " + method.getName() + " " + 
  10:                             method.getURI() + " " + method.getParams().getVersion());
  11:                     Header[] headers = method.getRequestHeaders();

View Full Code Here
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.HttpStatus;
   4:         ...
   5:     public static void executeMethodRedirecting(HttpClient client,
   6:                                                 HttpMethod methid)
   7:       throws IOException, HttpException {
   8:         ...
   9:     public static void executeMethodRedirecting(HttpClient client,
  10:                                                 HttpMethod methid,
  11:                                                 int redirects)
  12:         ...
  13:                 LOG.info("Attempting connection (" + i + ") to " + 
  14:                          methid.getURI().getEscapedURI());

View Full Code Here
   1: import org.apache.commons.httpclient.NameValuePair;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.HttpClient;
   4:         ...
   5:         String uri = genUri( "http", server.getHostname(), server.getPort(), webapp.getServletUri() );
   6:         HttpMethod method = new GetMethod( uri );
   7:         queryParams[2] = configParam;
   8:         ...
   9: 
  10:     private static InputStream executeXMLRequest( HttpMethod method, String uri, String resourceIdentifier )
  11:             throws ConfigException {
  12:         ...
  13:                 if ( log.isWarnEnabled() ) {
  14:                     String msg = "A recoverable exception occurred calling URI( " + method.getURI() +

View Full Code Here

hasBeenUsed

public boolean hasBeenUsed()
Returns true if the HTTP method has been already executed, but not recycled.
Returns:
true if the method has been executed, false otherwise

isRequestSent

public boolean isRequestSent()
Returns true if the HTTP has been transmitted to the target server in its entirety, false otherwise. This flag can be useful for recovery logic. If the request has not been transmitted in its entirety, it is safe to retry the failed method.
Returns:
true if the request has been sent, false otherwise

isStrictMode

public boolean isStrictMode()

Deprecated. Use HttpParams.setParameter(String,Object) 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

recycle

public void recycle()

Deprecated. no longer supported and will be removed in the future version of HttpClient

Recycles the HTTP method so that it can be used again. Note that all of the instance variables will be reset once this method has been called. This method will also release the connection being used by this HTTP method.
Usages and Demos :

View More Examples of recycle()
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.methods.GetMethod;
   4:         ...
   5:         throws IOException, HttpException {
   6:         HttpMethod method = new GetMethod( url );
   7:         client.executeMethod( method );
   8:         ...
   9:         method.releaseConnection();
  10:         method.recycle();
  11:     }

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

View Full Code Here
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.methods.GetMethod;
   4:         ...
   5:         HttpClient client = new HttpClient();
   6:         HttpMethod method = new GetMethod( url );
   7:     
   8:         ...
   9:             method.releaseConnection();
  10:             method.recycle();
  11:         }

View Full Code Here
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory;
   4:         ...
   5:         
   6:         HttpMethod method = new GetMethod( url );
   7:         client.executeMethod( method );
   8:         ...
   9:         method.releaseConnection();
  10:         method.recycle();
  11:     }

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

View Full Code Here

releaseConnection

public void releaseConnection()
Releases the connection being used by this HTTP method. In particular the connection is used to read the response (if there is one) and will be held until the response has been read. If the connection can be reused by other HTTP methods it is NOT closed at this point.

After this method is called, getResponseBodyAsStream() will return null, and getResponseBody() and getResponseBodyAsString() may return null.

Usages and Demos :

View More Examples of releaseConnection()
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.methods.GetMethod;
   4:         ...
   5:         throws IOException, HttpException {
   6:         HttpMethod method = new GetMethod( url );
   7:         client.executeMethod( method );
   8:         ...
   9:         System.out.println( response );
  10:         method.releaseConnection();
  11:         method.recycle();

View Full Code Here
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.methods.GetMethod;
   4:         ...
   5:         HttpClient client = new HttpClient();
   6:         HttpMethod method = new GetMethod( url );
   7:         client.executeMethod( method );
   8:         ...
   9:         System.out.println( response );
  10:         method.releaseConnection();
  11:         method.recycle();

View Full Code Here
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.methods.GetMethod;
   4:         ...
   5:         HttpClient client = new HttpClient();
   6:         HttpMethod method = new GetMethod( url );
   7:     
   8:         ...
   9:         } finally {
  10:             method.releaseConnection();
  11:             method.recycle();

View Full Code Here
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.NTCredentials;
   4:         ...
   5: 
   6:         HttpMethod method = new GetMethod( url );
   7:     
   8:         ...
   9:         System.out.println( response );
  10:         method.releaseConnection();
  11:     }

View Full Code Here
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory;
   4:         ...
   5:         
   6:         HttpMethod method = new GetMethod( url );
   7:         client.executeMethod( method );
   8:         ...
   9:         System.out.println( response );
  10:         method.releaseConnection();
  11:         method.recycle();

View Full Code Here

removeRequestHeader

public void removeRequestHeader(String headerName)
Removes all request headers with the given name. Note that header-name matching is case insensitive.
Parameters:
headerName - the header name
Usages and Demos :

View More Examples of removeRequestHeader(String headerName)
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.HttpStatus;
   4:         ...
   5:     public static void executeMethodRedirecting(HttpClient client,
   6:                                                 HttpMethod methid)
   7:       throws IOException, HttpException {
   8:         ...
   9:     public static void executeMethodRedirecting(HttpClient client,
  10:                                                 HttpMethod methid,
  11:                                                 int redirects)
  12:         ...
  13:                 methid.setQueryString(newLocation.getEscapedQuery());
  14:                 methid.removeRequestHeader(HttpAuthenticator.WWW_AUTH_RESP);

View Full Code Here

removeRequestHeader

public void removeRequestHeader(Header header)
Removes the given request header.
Parameters:
header - the header
Since:
3.0
Usages and Demos :

View More Examples of removeRequestHeader(Header header)
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.HttpStatus;
   4:         ...
   5:     public static void executeMethodRedirecting(HttpClient client,
   6:                                                 HttpMethod methid)
   7:       throws IOException, HttpException {
   8:         ...
   9:     public static void executeMethodRedirecting(HttpClient client,
  10:                                                 HttpMethod methid,
  11:                                                 int redirects)
  12:         ...
  13:                 methid.setQueryString(newLocation.getEscapedQuery());
  14:                 methid.removeRequestHeader(HttpAuthenticator.WWW_AUTH_RESP);

View Full Code Here

setDoAuthentication

public void setDoAuthentication(boolean doAuthentication)
Sets whether or not the HTTP method should automatically handle HTTP authentication challenges (status code 401, etc.)
Parameters:
doAuthentication - true to process authentication challenges automatically, false otherwise.
Since:
2.0
Usages and Demos :

View More Examples of setDoAuthentication(boolean doAuthentication)
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.NameValuePair;
   4:         ...
   5:     
   6:     protected byte[] doPreemptiveAuthentication(HttpClient client,HttpMethod method, RenderRequest request, RenderResponse response)
   7:     {
   8:         ...
   9:             
  10:             method.setDoAuthentication(true);
  11:             method.getHostAuthState().setPreemptive();
  12:         ...
  13: 
  14:     protected boolean doRequestedAuthentication(HttpClient client,HttpMethod method, RenderRequest request, RenderResponse response)

View Full Code Here

setFollowRedirects

public void setFollowRedirects(boolean followRedirects)
Sets whether or not the HTTP method should automatically follow HTTP redirects (status code 302, etc.)
Parameters:
followRedirects - true if the method will automatically follow redirects, false otherwise.
Usages and Demos :

View More Examples of setFollowRedirects(boolean followRedirects)
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.methods.GetMethod;
   4:         ...
   5:         System.out.println( "Executing Method not following redirects: ");        
   6:         HttpMethod method = new GetMethod( url );
   7:         ...
   8:         method.setFollowRedirects( false );
   9:         executeMethod(client, method);
  10:         ...
  11:         method = new GetMethod( url );
  12:         method.setFollowRedirects( true );

View Full Code Here
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.cookie.CookiePolicy;
   4:         ...
   5: 
   6:     public HttpMethod createMethod(String anAction) {
   7:         String url = "/amuse/test/web/agent-invoker.jsp?action=" + anAction;
   8:         ...
   9:         HttpMethod method = null;
  10: 
  11:         ...
  12:         method = new GetMethod(url);
  13:         method.setFollowRedirects(true);

View Full Code Here
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.UsernamePasswordCredentials;
   4:         ...
   5:         String url = args[0];
   6:         HttpMethod method = null;
   7: 
   8:         ...
   9:             method = new GetMethod(url);
  10:             method.setFollowRedirects(true);

View Full Code Here
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.cookie.CookiePolicy;
   4:         ...
   5: 
   6:     public HttpMethod createMethod(String anAction) {
   7:         String url = "/amuse/test/web/http-connector.jsp?action=" + anAction;
   8:         ...
   9:         HttpMethod method = null;
  10: 
  11:         ...
  12:         method = new GetMethod(url);
  13:         method.setFollowRedirects(true);

View Full Code Here
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.HttpStatus;
   4:         ...
   5:     public static void executeMethodRedirecting(HttpClient client,
   6:                                                 HttpMethod methid)
   7:       throws IOException, HttpException {
   8:         ...
   9:     public static void executeMethodRedirecting(HttpClient client,
  10:                                                 HttpMethod methid,
  11:                                                 int redirects)
  12:         ...
  13:                 
  14:                 methid.setFollowRedirects(true);

View Full Code Here

setParams

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

setPath

public void setPath(String path)
Sets the path of the HTTP method. It is responsibility of the caller to ensure that the path is properly encoded (URL safe).
Parameters:
path - The path of the HTTP method. The path is expected to be URL encoded.
Usages and Demos :

View More Examples of setPath(String path)
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.HttpStatus;
   4:         ...
   5:     public static void executeMethodRedirecting(HttpClient client,
   6:                                                 HttpMethod methid)
   7:       throws IOException, HttpException {
   8:         ...
   9:     public static void executeMethodRedirecting(HttpClient client,
  10:                                                 HttpMethod methid,
  11:                                                 int redirects)
  12:         ...
  13:                 
  14:                 methid.setPath(newLocation.getEscapedPath());

View Full Code Here
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.NameValuePair;
   4:         ...
   5: 
   6:     private HttpMethod start;
   7: 
   8:         ...
   9:     private HttpMethod stop;
  10: 
  11:         ...
  12:             start.recycle();
  13:             start.setPath(startPath);

View Full Code Here

setQueryString

public void setQueryString(String queryString)
Sets the query string of the HTTP method. It is responsibility of the caller to ensure that the path is properly encoded (URL safe). The string must not include an initial '?' character.
Parameters:
queryString - the query to be used in the request, with no leading '?' character
Usages and Demos :

View More Examples of setQueryString(String queryString)
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.NameValuePair;
   4:         ...
   5: 
   6:         HttpMethod method = new GetMethod( url );
   7:         ...
   8:         method.setQueryString( URIUtil.encodeQuery( "test1=O'Reilly&blah=Whoop" ) );
   9:         System.out.println( "With Query String: " + method.getURI() );
  10:         ...
  11:         NameValuePair[] pairs = new NameValuePair[] { pair, pair2 };
  12:         method.setQueryString( pairs );

View Full Code Here
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.HttpState;
   4:         ...
   5: 
   6:         HttpMethod getMethod = new GetMethod("/" + method);
   7:         ...
   8:         getMethod.setQueryString(query);
   9:         try {

View Full Code Here
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.HttpStatus;
   4:         ...
   5:     public static void executeMethodRedirecting(HttpClient client,
   6:                                                 HttpMethod methid)
   7:       throws IOException, HttpException {
   8:         ...
   9:     public static void executeMethodRedirecting(HttpClient client,
  10:                                                 HttpMethod methid,
  11:                                                 int redirects)
  12:         ...
  13:                 methid.setPath(newLocation.getEscapedPath());
  14:                 methid.setQueryString(newLocation.getEscapedQuery());

View Full Code Here
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.NameValuePair;
   4:         ...
   5: 
   6:     private HttpMethod start;
   7: 
   8:         ...
   9:     private HttpMethod stop;
  10: 
  11:         ...
  12:         {
  13:             start.setQueryString(buildPathQueryArgs(appPath));

View Full Code Here
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.StatusLine;
   4:         ...
   5:     
   6:                 HttpMethod method = new GetMethod(url);
   7:         ...
   8:                 method.setQueryString("digitalAssetId=" + digitalAssetId);
   9:                 method.setFollowRedirects(true);

View Full Code Here

setQueryString

public void setQueryString(NameValuePair[] params)
Sets the query string of this HTTP method. The pairs are encoded as UTF-8 characters. To use a different charset the parameters can be encoded manually using EncodingUtil and set as a single String.
Parameters:
params - An array of NameValuePairs to use as the query string. The name/value pairs will be automatically URL encoded and should not have been encoded previously.
Usages and Demos :

View More Examples of setQueryString(NameValuePair[] params)
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.NameValuePair;
   4:         ...
   5: 
   6:         HttpMethod method = new GetMethod( url );
   7:         ...
   8:         method.setQueryString( URIUtil.encodeQuery( "test1=O'Reilly&blah=Whoop" ) );
   9:         System.out.println( "With Query String: " + method.getURI() );
  10:         ...
  11:         NameValuePair[] pairs = new NameValuePair[] { pair, pair2 };
  12:         method.setQueryString( pairs );

View Full Code Here
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.HttpState;
   4:         ...
   5: 
   6:         HttpMethod getMethod = new GetMethod("/" + method);
   7:         ...
   8:         getMethod.setQueryString(query);
   9:         try {

View Full Code Here
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.HttpStatus;
   4:         ...
   5:     public static void executeMethodRedirecting(HttpClient client,
   6:                                                 HttpMethod methid)
   7:       throws IOException, HttpException {
   8:         ...
   9:     public static void executeMethodRedirecting(HttpClient client,
  10:                                                 HttpMethod methid,
  11:                                                 int redirects)
  12:         ...
  13:                 methid.setPath(newLocation.getEscapedPath());
  14:                 methid.setQueryString(newLocation.getEscapedQuery());

View Full Code Here
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.NameValuePair;
   4:         ...
   5: 
   6:     private HttpMethod start;
   7: 
   8:         ...
   9:     private HttpMethod stop;
  10: 
  11:         ...
  12:         {
  13:             start.setQueryString(buildPathQueryArgs(appPath));

View Full Code Here
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.StatusLine;
   4:         ...
   5:     
   6:                 HttpMethod method = new GetMethod(url);
   7:         ...
   8:                 method.setQueryString("digitalAssetId=" + digitalAssetId);
   9:                 method.setFollowRedirects(true);

View Full Code Here

setRequestHeader

public void setRequestHeader(String headerName,
                             String headerValue)
Sets the specified request header, overwriting any previous value. Note that header-name matching is case insensitive.
Parameters:
headerName - the header's name
headerValue - the header's value
Usages and Demos :

View More Examples of setRequestHeader(String headerName,String headerValue)
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.HttpStatus;
   4:         ...
   5:     public void asyncSend(Packet packet) throws JMSException {
   6:         PostMethod httpMethod = new PostMethod(getRemoteUrl());
   7:         ...
   8:         configureMethod(httpMethod);
   9:         httpMethod.setRequestBody(getTextWireFormat().toString(packet));
  10:         ...
  11:         if (clientID != null) {
  12:             method.setRequestHeader("clientID", clientID);

View Full Code Here
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.HttpStatus;
   4:         ...
   5:     public void asyncSend(Packet packet) throws JMSException {
   6:         PostMethod httpMethod = new PostMethod(getRemoteUrl());
   7:         ...
   8:         configureMethod(httpMethod);
   9:         httpMethod.setRequestBody(getTextWireFormat().toString(packet));
  10:         ...
  11:         if (clientID != null) {
  12:             method.setRequestHeader("clientID", clientID);

View Full Code Here
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.HttpStatus;
   4:         ...
   5:         
   6:         PostMethod httpMethod = new PostMethod(getRemoteUrl().toString());
   7:         ...
   8:         configureMethod(httpMethod);
   9:         String data = getTextWireFormat().marshalText(command);
  10:         ...
  11:     protected void configureMethod(HttpMethod method) {
  12:         method.setRequestHeader("clientID", clientID);

View Full Code Here

setRequestHeader

public void setRequestHeader(Header header)
Sets the specified request header, overwriting any previous value. Note that header-name matching is case insensitive.
Parameters:
header - the header to be set
Usages and Demos :

View More Examples of setRequestHeader(Header header)
   1: import org.apache.commons.httpclient.HttpConnection;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.archive.util.HttpRecorder;
   4:         ...
   5: 
   6:     public void handleAddProxyConnectionHeader(HttpMethod method) {
   7:         Header h = method.getRequestHeader("Proxy-Connection");
   8:         ...
   9:             h.setValue("close");
  10:             method.setRequestHeader(h);
  11:         }

View Full Code Here

setStrictMode

public void setStrictMode(boolean strictMode)

Deprecated. Use HttpParams.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
Usages and Demos :

View More Examples of setStrictMode(boolean strictMode)
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.cookie.CookiePolicy;
   4:         ...
   5: 
   6:     public HttpMethod createMethod(String anAction) {
   7:         String url = "/amuse/test/web/agent-invoker.jsp?action=" + anAction;
   8:         ...
   9:         HttpMethod method = null;
  10: 
  11:         ...
  12:         method.setFollowRedirects(true);
  13:         method.setStrictMode(false);

View Full Code Here
   1: import org.apache.commons.httpclient.HttpException;
   2: import org.apache.commons.httpclient.HttpMethod;
   3: import org.apache.commons.httpclient.cookie.CookiePolicy;
   4:         ...
   5: 
   6:     public HttpMethod createMethod(String anAction) {
   7:         String url = "/amuse/test/web/http-connector.jsp?action=" + anAction;
   8:         ...
   9:         HttpMethod method = null;
  10: 
  11:         ...
  12:         method.setFollowRedirects(true);
  13:         method.setStrictMode(false);

View Full Code Here

setURI

public void setURI(URI uri)
            throws URIException
Sets the URI for this method.
Parameters:
uri - URI to be set
Throws:
URIException - if a URI cannot be set
Since:
3.0

validate

public boolean validate()
Returns true the method is ready to execute, false otherwise.
Returns:
true if the method is ready to execute, false otherwise.