com.ibm.etill.framework.clientapi
Class HttpResponseHeader

java.lang.Object
  com.ibm.etill.framework.clientapi.HttpResponseHeader

public class HttpResponseHeader
extends java.lang.Object

The HttpResponseHeader class is used to encapsulate an HTTP protocol response header (but not the HTTP body). This response is typically created from an input stream associated with a TCP socket connection but any input stream containing a proper HTTP protocol response will do.

This class is meant to parse and give access to the very basics of an HTTP protocol response. In that sense it is a "light-weight" class that does little scrutiny of the header fields.

The input stream given on the constructor is used to read the HTTP header of the response. No portion of the optional body is read by this object from the input stream ... so that if there is a body, it can be read immediately following the creation of an object of this class.


Constructor Summary
HttpResponseHeader(java.io.InputStream stream)
Create an HTTP response header object by reading its contents from an input stream.
Method Summary
int getBodySize()
Return the size (in bytes) of the body or -1 if not determinable (body may not exist)
int getByteCountReceived()
Returns the number of bytes received from the socket connection with the server that made up this response
java.util.Hashtable getHeaderFields()
Returns a hashtable of header fields and values from the HTTP response.
java.lang.String getProtocol()
Returns the protocol field from the HTTP status line (example: "HTTP")
java.lang.String getReasonPhrase()
Returns the reason phrase field from the HTTP status line (example: "Unauthorized")
java.lang.String getStatusCode()
Returns the status code field from the HTTP status line (example: "401")
java.lang.String toString()
Returns a string representation of this object.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail

HttpResponseHeader

public HttpResponseHeader(java.io.InputStream stream)
                   throws java.io.IOException
Create an HTTP response header object by reading its contents from an input stream.
Parameters:
stream - The input stream containing an HTTP response header used to create the object.
Throws:
java.io.IOException - If the format or length of the input stream was not recognized as an HTTP response.
Method Detail

getProtocol

public java.lang.String getProtocol()
Returns the protocol field from the HTTP status line (example: "HTTP")

getStatusCode

public java.lang.String getStatusCode()
Returns the status code field from the HTTP status line (example: "401")

getReasonPhrase

public java.lang.String getReasonPhrase()
Returns the reason phrase field from the HTTP status line (example: "Unauthorized")

getHeaderFields

public java.util.Hashtable getHeaderFields()
Returns a hashtable of header fields and values from the HTTP response. The order of the header fields in the input stream has been lost (and according to HTTP specification is not required). Thus the order in the hashtable is not the same order that they were in the input stream.

The hashtable keys are header field names and their mapped values are the associated field values both contained in the HTTP message header.


getBodySize

public int getBodySize()
Return the size (in bytes) of the body or -1 if not determinable (body may not exist)

getByteCountReceived

public int getByteCountReceived()
Returns the number of bytes received from the socket connection with the server that made up this response

toString

public java.lang.String toString()
Returns a string representation of this object.

Feedback