cmsc433.http
Class HttpRequest

java.lang.Object
  extended bycmsc433.http.HttpMessage
      extended bycmsc433.http.HttpRequest

public class HttpRequest
extends HttpMessage

This class is used for managing the header of an http request message. The main method for creating requests is the parseRequest(java.io.InputStream) method.

See Also:
HttpMessage

Field Summary
 
Fields inherited from class cmsc433.http.HttpMessage
body, command
 
Constructor Summary
HttpRequest(java.lang.String fullcommand)
          Creates an HttpRequest object where fullcommand is assumed to be of the form
TYPE TARGET VERSION
GET /foo.gif HTTP/1.0
HttpRequest(java.lang.String type, java.lang.String target)
          Creates an HttpRequest object with the type and target given.
HttpRequest(java.lang.String type, java.lang.String target, java.lang.String version)
          Creates an HttpRequest object with the type target and version given.
 
Method Summary
 java.lang.String getTarget()
           
 java.lang.String getType()
           
 java.lang.String getVersion()
           
static HttpRequest parseRequest(java.io.InputStream in)
          Read an httpRequest from an inputstream.
 void setTarget(java.lang.String target)
          Sets the target of the request (/foo/bar.txt) to the specified type
 void setType(java.lang.String type)
          Sets the type of the request (GET,POST, HEAD, etc) to the specified type
 void setVersion(java.lang.String version)
          Sets the version of the request (HTTP/1.0) to the specified version
 
Methods inherited from class cmsc433.http.HttpMessage
getHeaderField, getHeaderFields, parse, parseMessage, send, send, setBody, setHeaderField, setHeaderFields, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HttpRequest

public HttpRequest(java.lang.String fullcommand)
Creates an HttpRequest object where fullcommand is assumed to be of the form
TYPE TARGET VERSION
GET /foo.gif HTTP/1.0


HttpRequest

public HttpRequest(java.lang.String type,
                   java.lang.String target,
                   java.lang.String version)
Creates an HttpRequest object with the type target and version given. Unless otherwise changed the first line of the send command will be the result of
type +" "+target+" "+version


HttpRequest

public HttpRequest(java.lang.String type,
                   java.lang.String target)
Creates an HttpRequest object with the type and target given. Unless otherwise changed the first line of the send command will be the result of
type +" "+target+" "+"HTTP/1.0/

Method Detail

getType

public java.lang.String getType()
Returns:
The type of the request (GET,POST,HEAD,etc)

setType

public void setType(java.lang.String type)
Sets the type of the request (GET,POST, HEAD, etc) to the specified type


getTarget

public java.lang.String getTarget()
Returns:
The target of the request (/foo/bar.html)

setTarget

public void setTarget(java.lang.String target)
Sets the target of the request (/foo/bar.txt) to the specified type


getVersion

public java.lang.String getVersion()
Returns:
The version of the request (HTTP/1.0)

setVersion

public void setVersion(java.lang.String version)
Sets the version of the request (HTTP/1.0) to the specified version


parseRequest

public static HttpRequest parseRequest(java.io.InputStream in)
                                throws java.io.IOException
Read an httpRequest from an inputstream. Any stream will do for debugging, but intended for socket.getInputStream().

Throws:
java.io.IOException