org.apache.commons.httpclient.methods
Class GetMethod

java.lang.Object
  |
  +--org.apache.commons.httpclient.HttpMethodBase
        |
        +--org.apache.commons.httpclient.methods.GetMethod
All Implemented Interfaces:
HttpMethod
Direct Known Subclasses:
PostMethod, UrlGetMethod

public class GetMethod
extends HttpMethodBase

GET Method. Implements an HTTP GET request.

Since:
1.0
Author:
Remy Maucherat, Sung-Gu Park, Sean C. Sullivan

Fields inherited from class org.apache.commons.httpclient.HttpMethodBase
USER_AGENT
 
Constructor Summary
GetMethod()
          No-arg constructor.
GetMethod(java.lang.String path)
          Path-setting constructor.
GetMethod(java.lang.String path, java.io.File fileData)
          Constructor.
GetMethod(java.lang.String path, java.lang.String tempDir)
          Constructor.
GetMethod(java.lang.String path, java.lang.String tempDir, java.lang.String tempFile)
          Constructor.
 
Method Summary
 java.io.File getFileData()
          File data getter.
 java.lang.String getName()
          Returns "GET".
 byte[] getResponseBody()
          Return my response body, if any, as a byte array.
 java.io.InputStream getResponseBodyAsStream()
          Return my response body, if any, as an InputStream.
 java.lang.String getTempDir()
          Temporary directory getter.
 java.lang.String getTempFile()
          Temporary file getter.
 boolean getUseDisk()
          Tells if the response will be buffered in a file.
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(java.io.File fileData)
          File data setter.
 void setTempDir(java.lang.String tempDir)
          Temporary directory setter.
 void setTempFile(java.lang.String tempFile)
          Temporary file setter.
 void setUseDisk(boolean useDisk)
          Buffer the response in a file or not.
 
Methods inherited from class org.apache.commons.httpclient.HttpMethodBase
addAuthorizationRequestHeader, addContentLengthRequestHeader, addCookieRequestHeader, addHostRequestHeader, addProxyAuthorizationRequestHeader, addRequestHeader, addRequestHeader, addRequestHeaders, addResponseFooter, addUserAgentRequestHeader, checkNotUsed, checkUsed, execute, generateRequestLine, getFollowRedirects, getPath, getQueryString, getRequestContentLength, getRequestHeader, getRequestHeaders, getResponseBodyAsString, getResponseFooter, getResponseFooters, getResponseHeader, getResponseHeaders, getStatusCode, getStatusText, hasBeenUsed, isHttp11, isStrictMode, processResponseBody, processResponseHeaders, processStatusLine, readResponse, readResponseHeaders, readStatusLine, removeRequestHeader, setFollowRedirects, setHttp11, setPath, setQueryString, setQueryString, setRequestHeader, setRequestHeader, setResponseStream, setStrictMode, 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(java.lang.String path)
Path-setting constructor.
Parameters:
path - the path to request
Since:
1.0

GetMethod

public GetMethod(java.lang.String path,
                 java.lang.String tempDir)
Constructor.
Parameters:
path - the path to request
tempDir - the directory in which to store temporary files
Since:
1.0

GetMethod

public GetMethod(java.lang.String path,
                 java.lang.String tempDir,
                 java.lang.String tempFile)
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(java.lang.String path,
                 java.io.File fileData)
Constructor.
Parameters:
path - the path to request
fileData - the file to buffer contents to
Since:
1.0
Method Detail

setFileData

public void setFileData(java.io.File fileData)
File data setter.
Parameters:
fileData - the file to buffer data to
Since:
1.0

getFileData

public java.io.File getFileData()
File data getter.
Returns:
the file being used for buffering data
Since:
1.0

getName

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

getResponseBody

public byte[] getResponseBody()
Return my response body, if any, as a byte array. Otherwise return null.
Overrides:
getResponseBody in class HttpMethodBase
Returns:
the response body as a byte array
Since:
2.0

getResponseBodyAsStream

public java.io.InputStream getResponseBodyAsStream()
                                            throws java.io.IOException
Return my response body, if any, as an InputStream. Otherwise return null.
Overrides:
getResponseBodyAsStream in class HttpMethodBase
Returns:
a stream to read the response from
Throws:
java.io.IOException - when there is an error reading the response
Since:
2.0

setTempDir

public void setTempDir(java.lang.String tempDir)
Temporary directory setter.
Parameters:
tempDir - New value of tempDir
Since:
1.0

getTempDir

public java.lang.String getTempDir()
Temporary directory getter.
Returns:
the current temporary directory
Since:
1.0

setTempFile

public void setTempFile(java.lang.String tempFile)
Temporary file setter.
Parameters:
tempFile - New value of tempFile
Since:
1.0

getTempFile

public java.lang.String getTempFile()
Temporary file getter.
Returns:
the current temporary file
Since:
1.0

setUseDisk

public void setUseDisk(boolean useDisk)
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()
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 java.io.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:
java.io.IOException - when there are problems reading from the connection
Since:
2.0


Copyright (c) 2001 - Apache Software Foundation