Class HTTPClient.HTTPResponse
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class HTTPClient.HTTPResponse

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

public class HTTPResponse
extends Object
This defines the http-response class returned by the requests.
Version:
0.2 (bug fix 2) 23/03/1997
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 field for a given header.
 o getHeaderAsDate(String)
retrieves the field for a given header.
 o getHeaderAsInt(String)
retrieves the field 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.
 o getStatusCode()
give the status code for this request.
 o getVersion()
get the HTTP version used for the response.
 o listHeaders()
returns an enumeration of all the headers available via getHeader().
 o toString()
produces a full list of headers and their values, one per line.

Methods

 o getStatusCode
  public final int getStatusCode() throws IOException
give the status code for this request. These are grouped as follows:
Throws: IOException
If any exception occurs on the socket.
 o getReasonLine
  public final String getReasonLine() throws IOException
give the reason line associated with the status code.
Throws: IOException
If any exception occurs on the socket.
 o getVersion
  public final String getVersion() throws IOException
get the HTTP version used for the response.
Throws: IOException
If any exception occurs on the socket.
 o getServer
  public final String getServer() throws IOException
get the name and type of server.
Throws: IOException
If any exception occurs on the socket.
 o getEffectiveURL
  public final URL getEffectiveURL() throws IOException
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.
 o getHeader
  public String getHeader(String hdr) throws IOException
retrieves the field 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.
 o getHeaderAsInt
  public int getHeaderAsInt(String hdr) throws IOException
retrieves the field for a given header. The value is parsed as an int.
Parameters:
hdr - the header name.
Returns:
the value for the header, or -1 if non-existent.
Throws: IOException
If any exception occurs on the socket.
 o getHeaderAsDate
  public Date getHeaderAsDate(String hdr) throws IOException
retrieves the field for a given header. The value is parsed as a date.
Note: When sending dates use .toGMTString() .
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.
 o listHeaders
  public Enumeration listHeaders() throws IOException
returns an enumeration of all the headers available via getHeader().
Throws: IOException
If any exception occurs on the socket.
 o getData
  public synchronized byte[] getData() throws IOException
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 called 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
See Also:
getInputStream
 o getInputStream
  public synchronized InputStream getInputStream() throws IOException
Gets an input stream from which the returned data can be read. Note that if getData() had been previously called it will actually return a ByteArrayInputStream created from that data.
Returns:
the InputStream.
Throws: IOException
If any exception occurs on the socket.
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
Throws: IOException
if an exception occurs while reading the headers.
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index