netapp.manage.http
Class HTTPResponse

java.lang.Object
  extended bynetapp.manage.http.HTTPMessage
      extended bynetapp.manage.http.HTTPResponse

public class HTTPResponse
extends HTTPMessage

This class represents a HTTP response.


Field Summary
 
Fields inherited from class netapp.manage.http.HTTPMessage
_contents, _header, _headerLowerCase, _version, METHOD_GET, METHOD_POST, VERSION_1_0, VERSION_1_1
 
Constructor Summary
HTTPResponse(int version, int statusCode, java.lang.String reasonPhrase)
          Constructs a HTTPResponse.
 
Method Summary
 boolean canKeepAlive()
          Determine whether this response indicates that the socket can be used for additional requests.
protected  java.lang.String firstLine()
          Get the first (status) line of this HTTP response.
 java.lang.String getReasonPhrase()
          Get the textual status of this response.
 int getStatusCode()
          Get the HTTP status of this response.
static HTTPResponse read(java.io.InputStream in)
          Create a new HTTP response by reading data from a socket.
 
Methods inherited from class netapp.manage.http.HTTPMessage
getContents, getHeader, headersString, methodFromString, methodToString, processHeaderLine, readContents, readLine, removeHeader, setContents, setHeader, toString, versionFromString, versionToString, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HTTPResponse

public HTTPResponse(int version,
                    int statusCode,
                    java.lang.String reasonPhrase)
Constructs a HTTPResponse.

Parameters:
version - the HTTP version.
statusCode - the HTTP status of the response.
reasonPhrase - a textual description of the status (may be empty).
Method Detail

getStatusCode

public int getStatusCode()
Get the HTTP status of this response. It should be a 3 digit decimal number.

Returns:
the HTTP status.

getReasonPhrase

public java.lang.String getReasonPhrase()
Get the textual status of this response. This is usually meant for human readability, as getStatusCode() contains all the relevant information.

Returns:
the reason phrase (may be empty).

read

public static HTTPResponse read(java.io.InputStream in)
                         throws java.io.IOException,
                                HTTPException
Create a new HTTP response by reading data from a socket.

Parameters:
in - an InputStream, presumably connected to a client socket.
Returns:
a new HTTPResponse.
Throws:
java.io.IOException - if there is a communication error on the InputStream.
HTTPException - if the HTTP response is malformed.

canKeepAlive

public boolean canKeepAlive()
Determine whether this response indicates that the socket can be used for additional requests.

Returns:
true if the socket can be reused, otherwise false.

firstLine

protected java.lang.String firstLine()
Get the first (status) line of this HTTP response.

Specified by:
firstLine in class HTTPMessage
Returns:
a string representing one line.