All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class HTTPClient.HTTPResponse

java.lang.Object
    |
    +----HTTPClient.HTTPResponse

public class HTTPResponse
extends Object
implements GlobalConstants, HTTPClientModuleConstants
This defines the http-response class returned by the requests. It's basically a wrapper around the Response class which first lets all the modules handle the response before finally giving the info to the user.

Since:
0.3
Version:
0.3 30/01/1998
Author:
Ronald Tschalär

Method Index

 o getData()
Reads all the response data into a byte array.
 o getEffectiveURL()
Get the final URL of the document.
 o getHeader(String)
Retrieves the value for a given header.
 o getHeaderAsDate(String)
Retrieves the value for a given header.
 o getHeaderAsInt(String)
Retrieves the value for a given header.
 o getInputStream()
Gets an input stream from which the returned data can be read.
 o getReasonLine()
Give the reason line associated with the status code.
 o getServer()
Get the name and type of server. Deprecated.
 o getStatusCode()
Give the status code for this request.
 o getTrailer(String)
Retrieves the value for a given trailer.
 o getTrailerAsDate(String)
Retrieves the value for a given trailer.
 o getTrailerAsInt(String)
Retrieves the value for a given tailer.
 o getVersion()
Get the HTTP version used for the response.
 o listHeaders()
Returns an enumeration of all the headers available via getHeader().
 o listTrailers()
Returns an enumeration of all the trailers available via getTrailer().
 o toString()
produces a full list of headers and their values, one per line.

Methods

 o getStatusCode
public final int getStatusCode() throws IOException, ModuleException
Give the status code for this request. These are grouped as follows:

Throws: IOException
if any exception occurs on the socket.
Throws: ModuleException
if any module encounters an exception.
 o getReasonLine
public final String getReasonLine() throws IOException, ModuleException
Give the reason line associated with the status code.

Throws: IOException
If any exception occurs on the socket.
Throws: ModuleException
if any module encounters an exception.
 o getVersion
public final String getVersion() throws IOException, ModuleException
Get the HTTP version used for the response.

Throws: IOException
If any exception occurs on the socket.
Throws: ModuleException
if any module encounters an exception.
 o getServer
public final String getServer() throws IOException, ModuleException
Note: getServer() is deprecated. This method is a remnant of V0.1; use getHeader("Server") instead.

Get the name and type of server.

Throws: IOException
If any exception occurs on the socket.
Throws: ModuleException
if any module encounters an exception.
See Also:
getHeader
 o getEffectiveURL
public final URL getEffectiveURL() throws IOException, ModuleException
Get the final URL of the document. This is set if the original request was deferred via the "moved" (301, 302, or 303) return status.

Throws: IOException
If any exception occurs on the socket.
Throws: ModuleException
if any module encounters an exception.
 o getHeader
public String getHeader(String hdr) throws IOException, ModuleException
Retrieves the value for a given header.

Parameters:
hdr - the header name.
Returns:
the value for the header, or null if non-existent.
Throws: IOException
If any exception occurs on the socket.
Throws: ModuleException
if any module encounters an exception.
 o getHeaderAsInt
public int getHeaderAsInt(String hdr) throws IOException, ModuleException, NumberFormatException
Retrieves the value for a given header. The value is parsed as an int.

Parameters:
hdr - the header name.
Returns:
the value for the header if the header exists
Throws: NumberFormatException
if the header's value is not a number or if the header does not exist.
Throws: IOException
if any exception occurs on the socket.
Throws: ModuleException
if any module encounters an exception.
 o getHeaderAsDate
public Date getHeaderAsDate(String hdr) throws IOException, IllegalArgumentException, ModuleException
Retrieves the value for a given header. The value is parsed as a date; if this fails it is parsed as a long representing the number of seconds since 12:00 AM, Jan 1st, 1970. If this also fails an exception is thrown.
Note: When sending dates use Util.httpDate().

Parameters:
hdr - the header name.
Returns:
the value for the header, or null if non-existent.
Throws: IllegalArgumentException
if the header's value is neither a legal date nor a number.
Throws: IOException
if any exception occurs on the socket.
Throws: ModuleException
if any module encounters an exception.
 o listHeaders
public Enumeration listHeaders() throws IOException, ModuleException
Returns an enumeration of all the headers available via getHeader().

Throws: IOException
If any exception occurs on the socket.
Throws: ModuleException
if any module encounters an exception.
 o getTrailer
public String getTrailer(String trailer) throws IOException, ModuleException
Retrieves the value for a given trailer. This should not be invoked until all response data has been read. If invoked before it will call getData() to force the data to be read.

Parameters:
trailer - the trailer name.
Returns:
the value for the trailer, or null if non-existent.
Throws: IOException
If any exception occurs on the socket.
Throws: ModuleException
if any module encounters an exception.
See Also:
getData
 o getTrailerAsInt
public int getTrailerAsInt(String trailer) throws IOException, ModuleException, NumberFormatException
Retrieves the value for a given tailer. The value is parsed as an int.

Parameters:
trailer - the tailer name.
Returns:
the value for the trailer if the trailer exists
Throws: NumberFormatException
if the trailer's value is not a number or if the trailer does not exist.
Throws: IOException
if any exception occurs on the socket.
Throws: ModuleException
if any module encounters an exception.
 o getTrailerAsDate
public Date getTrailerAsDate(String trailer) throws IOException, IllegalArgumentException, ModuleException
Retrieves the value for a given trailer. The value is parsed as a date; if this fails it is parsed as a long representing the number of seconds since 12:00 AM, Jan 1st, 1970. If this also fails an IllegalArgumentException is thrown.
Note: When sending dates use Util.httpDate().

Parameters:
trailer - the trailer name.
Returns:
the value for the trailer, or null if non-existent.
Throws: IllegalArgumentException
if the trailer's value is neither a legal date nor a number.
Throws: IOException
if any exception occurs on the socket.
Throws: ModuleException
if any module encounters an exception.
 o listTrailers
public Enumeration listTrailers() throws IOException, ModuleException
Returns an enumeration of all the trailers available via getTrailer().

Throws: IOException
If any exception occurs on the socket.
Throws: ModuleException
if any module encounters an exception.
 o getData
public byte[] getData() throws IOException, ModuleException
Reads all the response data into a byte array. Note that this method won't return until all the data has been received (so for instance don't invoke this method if the server is doing a server push). If getInputStream() had been previously invoked then this method only returns any unread data remaining on the stream and then closes it.

Returns:
an array containing the data (body) returned. If no data was returned then it's set to a zero-length array.
Throws: IOException
If any io exception occured while reading the data
Throws: ModuleException
if any module encounters an exception.
See Also:
getInputStream
 o getInputStream
public InputStream getInputStream() throws IOException, ModuleException
Gets an input stream from which the returned data can be read. Note that if getData() had been previously invoked it will actually return a ByteArrayInputStream created from that data.

Returns:
the InputStream.
Throws: IOException
If any exception occurs on the socket.
Throws: ModuleException
if any module encounters an exception.
See Also:
getData
 o toString
public String toString()
produces a full list of headers and their values, one per line.

Returns:
a string containing the headers
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index