netapp.manage.http
Class HTTPRequest

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

public class HTTPRequest
extends HTTPMessage

This class represents a HTTP request.


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
HTTPRequest(int method, java.lang.String path, int version)
          Constructs a HTTPRequest.
 
Method Summary
protected  java.lang.String firstLine()
          Get the first line of this HTTP request.
 int getMethod()
          Get the HTTP method of this request.
 java.lang.String getPath()
          Get the URI-path for this HTTP request.
static HTTPRequest read(java.io.InputStream in)
          Create a new HTTP request by reading data from a socket.
 void setBasicAuthorization(java.lang.String username, java.lang.String password)
          Add a header for HTTP Basic authentication.
 
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

HTTPRequest

public HTTPRequest(int method,
                   java.lang.String path,
                   int version)
Constructs a HTTPRequest.

Parameters:
method - the HTTP request method.
path - the URI path to request.
version - the HTTP version.
Method Detail

getMethod

public int getMethod()
Get the HTTP method of this request. It will be either HTTPMessage.METHOD_GET or HTTPMessage.METHOD_POST.

Returns:
the HTTP method.

getPath

public java.lang.String getPath()
Get the URI-path for this HTTP request.

Returns:
a URI-path string.

setBasicAuthorization

public void setBasicAuthorization(java.lang.String username,
                                  java.lang.String password)
Add a header for HTTP Basic authentication.

Parameters:
username - the username.
password - the password.

read

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

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

firstLine

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

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