org.apache.commons.httpclient.methods
Class GetMethod

java.lang.Object
  |
  +--org.apache.commons.httpclient.HttpMethodBase
        |
        +--org.apache.commons.httpclient.methods.GetMethod
Direct Known Subclasses:
ExpectContinueMethod, UrlGetMethod

public class GetMethod
extends HttpMethodBase

Implements the HTTP GET specification.

The HTTP GET method is defined in section 8.1 of RFC1945:

The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI. If the Request-URI refers to a data-producing process, it is the produced data which shall be returned as the entity in the response and not the source text of the process, unless that text happens to be the output of the process.

GetMethods will follow redirect requests from the http server by default. This behavour can be disabled by calling setFollowRedirects(false).

The useDisk methods have been deprecated. Disk I/O is the responsibility of the client. If you need to write a response body to a file, you can use the following as an example:

     out = new FileOutputStream(myFile);
     InputStream in = getResponseBodyAsStream();
     byte[] buffer = new byte[10000];
     int len ;
     while ((len = in.read(buffer)) > 0) {
        out.write(buffer, 0, len);
     }
     in.close();
     out.close();
 

Since:
1.0
Version:
$Revision: 1.24 $
Author:
Remy Maucherat, Sung-Gu Park, Sean C. Sullivan, Mike Bowler, Jeff Dever

Fields inherited from class org.apache.commons.httpclient.HttpMethodBase
USER_AGENT
 
Constructor Summary
GetMethod()
          No-arg constructor.
GetMethod(String uri)
          Constructor specifying a URI.
GetMethod(String path, File fileData)
          Deprecated. the client is responsible for disk I/O
GetMethod(String path, String tempDir)
          Deprecated. the client is responsible for disk I/O
GetMethod(String path, String tempDir, String tempFile)
          Deprecated. the client is responsible for disk I/O
 
Method Summary
 File getFileData()
          Deprecated. the client is responsible for disk I/O
 String getName()
          Returns "GET".
 String getTempDir()
          Deprecated. the client is responsible for disk I/O
 String getTempFile()
          Deprecated. the client is responsible for disk I/O
 boolean getUseDisk()
          Deprecated. the client is responsible for disk I/O
protected  void readResponseBody(HttpState state, HttpConnection conn)
          Overrides method in HttpMethodBase to write data to the appropriate buffer.
 void recycle()
          Override recycle to reset redirects default.
 void setFileData(File fileData)
          Deprecated. the client is responsible for disk I/O
 void setTempDir(String tempDir)
          Deprecated. the client is responsible for disk I/O
 void setTempFile(String tempFile)
          Deprecated. the client is responsible for disk I/O
 void setUseDisk(boolean useDisk)
          Deprecated. the client is responsible for disk I/O
 
Methods inherited from class org.apache.commons.httpclient.HttpMethodBase
addAuthorizationRequestHeader, addContentLengthRequestHeader, addCookieRequestHeader, addHostRequestHeader, addProxyAuthorizationRequestHeader, addProxyConnectionHeader, addRequestHeader, addRequestHeader, addRequestHeaders, addResponseFooter, addUserAgentRequestHeader, checkNotUsed, checkUsed, execute, fakeResponse, generateRequestLine, getAuthenticationRealm, getContentCharSet, getDoAuthentication, getFollowRedirects, getHostConfiguration, getMethodRetryHandler, getPath, getProxyAuthenticationRealm, getQueryString, getRecoverableExceptionCount, getRequestCharSet, getRequestContentLength, getRequestHeader, getRequestHeaderGroup, getRequestHeaders, getResponseBody, getResponseBodyAsStream, getResponseBodyAsString, getResponseCharSet, getResponseContentLength, getResponseFooter, getResponseFooters, getResponseHeader, getResponseHeaderGroup, getResponseHeaders, getResponseStream, getResponseTrailerHeaderGroup, getStatusCode, getStatusLine, getStatusText, getURI, hasBeenUsed, isConnectionCloseForced, isHttp11, isStrictMode, processResponseBody, processResponseHeaders, processStatusLine, readResponse, readResponseHeaders, readStatusLine, releaseConnection, removeRequestHeader, responseBodyConsumed, setConnectionCloseForced, setDoAuthentication, setFollowRedirects, setHostConfiguration, setHttp11, setMethodRetryHandler, setPath, setQueryString, setQueryString, setRequestHeader, setRequestHeader, setResponseStream, setStrictMode, shouldCloseConnection, validate, writeRequest, writeRequestBody, writeRequestHeaders, writeRequestLine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GetMethod

public GetMethod()
No-arg constructor.
Since:
1.0

GetMethod

public GetMethod(String uri)
Constructor specifying a URI.
Parameters:
uri - either an absolute or relative URI
Since:
1.0

GetMethod

public GetMethod(String path,
                 String tempDir)
Deprecated. the client is responsible for disk I/O

Constructor.
Parameters:
path - the path to request
tempDir - the directory in which to store temporary files
Since:
1.0

GetMethod

public GetMethod(String path,
                 String tempDir,
                 String tempFile)
Deprecated. the client is responsible for disk I/O

Constructor.
Parameters:
path - the path to request
tempDir - the directory in which to store temporary files
tempFile - the file (under tempDir) to buffer contents to
Since:
1.0

GetMethod

public GetMethod(String path,
                 File fileData)
Deprecated. the client is responsible for disk I/O

Constructor.
Parameters:
path - the path to request
fileData - the file to buffer contents to
Since:
1.0
Method Detail

setFileData

public void setFileData(File fileData)
Deprecated. the client is responsible for disk I/O

File data setter.
Parameters:
fileData - the file to buffer data to
Since:
1.0

getFileData

public File getFileData()
Deprecated. the client is responsible for disk I/O

File data getter.
Returns:
the file being used for buffering data
Since:
1.0

getName

public String getName()
Returns "GET".
Overrides:
getName in class HttpMethodBase
Returns:
"GET"
Since:
2.0

setTempDir

public void setTempDir(String tempDir)
Deprecated. the client is responsible for disk I/O

Temporary directory setter.
Parameters:
tempDir - New value of tempDir
Since:
1.0

getTempDir

public String getTempDir()
Deprecated. the client is responsible for disk I/O

Temporary directory getter.
Returns:
the current temporary directory
Since:
1.0

setTempFile

public void setTempFile(String tempFile)
Deprecated. the client is responsible for disk I/O

Temporary file setter.
Parameters:
tempFile - New value of tempFile
Since:
1.0

getTempFile

public String getTempFile()
Deprecated. the client is responsible for disk I/O

Temporary file getter.
Returns:
the current temporary file
Since:
1.0

setUseDisk

public void setUseDisk(boolean useDisk)
Deprecated. the client is responsible for disk I/O

Buffer the response in a file or not. The default is false.
Parameters:
useDisk - If true the entire response will be buffered in a temporary file.
Since:
1.0

getUseDisk

public boolean getUseDisk()
Deprecated. the client is responsible for disk I/O

Tells if the response will be buffered in a file.
Returns:
true if the response will be buffered
Since:
1.0

recycle

public void recycle()
Override recycle to reset redirects default.
Overrides:
recycle in class HttpMethodBase
Since:
1.0

readResponseBody

protected void readResponseBody(HttpState state,
                                HttpConnection conn)
                         throws IOException,
                                HttpException
Overrides method in HttpMethodBase to write data to the appropriate buffer.
Overrides:
readResponseBody in class HttpMethodBase
Parameters:
state - the shared http state
conn - the connection to read data from
Throws:
IOException - when there are problems reading from the connection
HttpException - when a protocol error occurs or state is invalid
Since:
2.0


Copyright © 2001-2003 Apache Software Foundation. All Rights Reserved.