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

public class GetMethod
extends HttpMethodBase

GET Method. Implements an HTTP GET request.

Author:
Remy Maucherat, Sung-Gu Park

Field Summary
protected  java.io.File fileData
          File which contains the buffered data.
protected  byte[] memoryData
          If we're not using the HD, we're using a memory byte buffer.
protected  java.lang.String tempDir
          Temporary directory to use.
protected  java.lang.String tempFile
          Temporary file to use.
protected  boolean useDisk
          By default, the get method will buffer read data to the memory.
 
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 getResponseBodyAsString()
          Return my response body, if any, as a String.
 java.lang.String getTempDir()
          Temporary directory getter.
 java.lang.String getTempFile()
          Temporary file getter.
 boolean getUseDisk()
          Use disk getter.
protected  void readResponseBody(HttpState state, HttpConnection conn)
          Overrides method in HttpMethodBase to write data to the appropriate buffer.
 void recycle()
          Recycle this method so that it can be used again.
 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)
          Use disk setter.
 
Methods inherited from class org.apache.commons.httpclient.HttpMethodBase
addAuthorizationRequestHeader, addContentLengthRequestHeader, addCookieRequestHeader, addHostRequestHeader, addRequestHeader, addRequestHeader, addRequestHeaders, addUserAgentRequestHeader, checkNotUsed, checkUsed, execute, followRedirects, generateRequestLine, getPath, getQueryString, getRequestContentLength, getRequestHeader, getRequestHeaders, getResponseHeader, getResponseHeaders, getStatusCode, getStatusText, hasBeenUsed, isHttp11, processResponseBody, processResponseHeaders, processStatusLine, readResponse, readResponseHeaders, readStatusLine, removeRequestHeader, setFollowRedirects, setHttp11, setPath, setQueryString, setQueryString, setRequestHeader, setRequestHeader, validate, writeRequest, writeRequestBody, writeRequestHeaders, writeRequestLine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

useDisk

protected boolean useDisk
By default, the get method will buffer read data to the memory.

memoryData

protected byte[] memoryData
If we're not using the HD, we're using a memory byte buffer.

fileData

protected java.io.File fileData
File which contains the buffered data.

tempDir

protected java.lang.String tempDir
Temporary directory to use.

tempFile

protected java.lang.String tempFile
Temporary file to use.
Constructor Detail

GetMethod

public GetMethod()
No-arg constructor.

GetMethod

public GetMethod(java.lang.String path)
Path-setting constructor.
Parameters:
path - the path to request

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

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

GetMethod

public GetMethod(java.lang.String path,
                 java.io.File fileData)
Constructor.
Parameters:
path - the path to request
tempFile - the file to buffer contents to
Method Detail

setUseDisk

public void setUseDisk(boolean useDisk)
Use disk setter.
Parameters:
useDisk - New value of useDisk

getUseDisk

public boolean getUseDisk()
Use disk getter.
Parameters:
boolean - useDisk value

setTempDir

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

getTempDir

public java.lang.String getTempDir()
Temporary directory getter.

setTempFile

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

getTempFile

public java.lang.String getTempFile()
Temporary file getter.

getFileData

public java.io.File getFileData()
File data getter.

setFileData

public void setFileData(java.io.File fileData)
File data setter.

getName

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

recycle

public void recycle()
Description copied from class: HttpMethodBase
Recycle this method so that it can be used again. All of my instances variables will be reset once this method has been called.
Overrides:
recycle in class HttpMethodBase

getResponseBody

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

getResponseBodyAsString

public java.lang.String getResponseBodyAsString()
Return my response body, if any, as a String. Otherwise return null.
Overrides:
getResponseBodyAsString in class HttpMethodBase

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

readResponseBody

protected void readResponseBody(HttpState state,
                                HttpConnection conn)
                         throws java.io.IOException
Overrides method in HttpMethodBase to write data to the appropriate buffer.
Overrides:
readResponseBody in class HttpMethodBase
Following copied from class: org.apache.commons.httpclient.HttpMethodBase
Parameters:
state - the client state
conn - the HttpConnection to read the response from
See Also:
HttpMethodBase.readResponse(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpConnection), HttpMethodBase.processResponseBody(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpConnection)


Copyright (c) 2001 - Apache Software Foundation