edu.neu.ccs.demeterf.http.classes
Class HTTPReq

java.lang.Object
  extended by edu.neu.ccs.demeterf.http.classes.HTTPReq

public class HTTPReq
extends java.lang.Object

Representation of HTTPReq


Nested Class Summary
static class HTTPReq.body
          Field Class for HTTPReq.body
static class HTTPReq.head
          Field Class for HTTPReq.head
static class HTTPReq.keys
          Field Class for HTTPReq.keys
static class HTTPReq.ReqType
          Request Types
 
Constructor Summary
HTTPReq(HTTPHead head, List<MsgHead> keys, ident body)
          Construct a(n) HTTPReq Instance
 
Method Summary
 Map<java.lang.String,java.lang.String> bodyArgs()
          Return the Body arguments (key/value) from this request.
static HTTPReq create(HTTPHead req, List<MsgHead> hds, java.lang.String body)
          Create an HTTP Request with a given Header, MessageHeaders, and Body
 boolean equals(java.lang.Object o)
          Is the given object Equal to this HTTPReq?
static HTTPReq fromInputStream(java.io.InputStream inpt)
          Read a Request from an InputStream
static HTTPReq fromSocket(java.net.Socket s)
          Read a request from a Socket
static HTTPReq Get(java.lang.String url)
          Create an HTTP Get Request for the given (relative) URL.
static HTTPReq Get(java.lang.String url, java.lang.String host)
          Create an HTTP Get Request for the given relative URL, to be sent to the given Host.
 ident getBody()
          Getter for field HTTPReq.body
 java.lang.String getBodyString()
          Return the Body of this Request
 HTTPHead getHead()
          Getter for field HTTPReq.head
 Map<java.lang.String,java.lang.String> getHeaders()
          Return the Headers of this Request as a Map
 List<MsgHead> getKeys()
          Getter for field HTTPReq.keys
 HTTPReq.ReqType getType()
          Return this Request's type
 HTTPResp handle(ReqHandler h)
          Handle this Request with the given Handler
static HTTPReq Head(java.lang.String url)
          Create an HTTP Head Request for the given (relative) URL.
static HTTPReq Head(java.lang.String url, java.lang.String host)
          Create an HTTP Head Request for the given relative URL, to be sent to the given Host.
static HTTPReq Post(java.lang.String url, java.lang.String body)
          Create an HTTP Post Request to the given (relative) URL.
static HTTPReq Post(java.lang.String url, java.lang.String host, java.lang.String body)
          Create an HTTP Post Request to the given relative URL, to be sent to the given Host.
 HTTPResp send(java.lang.String server, int port)
          Send this Request to the given Server/Port, and return its Response
 void toSocket(java.net.Socket s)
          Write this Request to the given Socket
 java.lang.String toString()
          DGP method from Class PrintToString
 java.lang.String trimmedUrl()
          Return the relative URL, without any URL arguments
 Map<java.lang.String,java.lang.String> urlArgs()
          Return the URL arguments (key/value) for this request.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HTTPReq

public HTTPReq(HTTPHead head,
               List<MsgHead> keys,
               ident body)
Construct a(n) HTTPReq Instance

Method Detail

equals

public boolean equals(java.lang.Object o)
Is the given object Equal to this HTTPReq?

Overrides:
equals in class java.lang.Object

create

public static HTTPReq create(HTTPHead req,
                             List<MsgHead> hds,
                             java.lang.String body)
Create an HTTP Request with a given Header, MessageHeaders, and Body


Get

public static HTTPReq Get(java.lang.String url)
                   throws ParseException
Create an HTTP Get Request for the given (relative) URL. Then use Send for a Request/Response pair.

Throws:
ParseException

Get

public static HTTPReq Get(java.lang.String url,
                          java.lang.String host)
                   throws ParseException
Create an HTTP Get Request for the given relative URL, to be sent to the given Host. Use this method for raw Socket/Connection sends, but use Send for a Request/Response pair.

Throws:
ParseException

Head

public static HTTPReq Head(java.lang.String url)
                    throws ParseException
Create an HTTP Head Request for the given (relative) URL. Then use Send for a Request/Response pair.

Throws:
ParseException

Head

public static HTTPReq Head(java.lang.String url,
                           java.lang.String host)
                    throws ParseException
Create an HTTP Head Request for the given relative URL, to be sent to the given Host. Use this method for raw Socket/Connection sends, but use Send for a Request/Response pair.

Throws:
ParseException

Post

public static HTTPReq Post(java.lang.String url,
                           java.lang.String body)
                    throws ParseException
Create an HTTP Post Request to the given (relative) URL. Then use Send for a Request/Response pair.

Throws:
ParseException

Post

public static HTTPReq Post(java.lang.String url,
                           java.lang.String host,
                           java.lang.String body)
                    throws ParseException
Create an HTTP Post Request to the given relative URL, to be sent to the given Host. Use this method for raw Socket/Connection sends, but use Send for a Request Response Pair.

Throws:
ParseException

getType

public HTTPReq.ReqType getType()
Return this Request's type


urlArgs

public Map<java.lang.String,java.lang.String> urlArgs()
Return the URL arguments (key/value) for this request. The URL arguments follow the base URL after a '?'. E.g.: /foo/bar?bazzle=13&wizwoz='hello'


bodyArgs

public Map<java.lang.String,java.lang.String> bodyArgs()
Return the Body arguments (key/value) from this request. The Body arguments are on a single line of the body, like URLArgs, but without the '?'


trimmedUrl

public java.lang.String trimmedUrl()
Return the relative URL, without any URL arguments


handle

public HTTPResp handle(ReqHandler h)
Handle this Request with the given Handler


send

public HTTPResp send(java.lang.String server,
                     int port)
              throws java.io.IOException
Send this Request to the given Server/Port, and return its Response

Throws:
java.io.IOException

toSocket

public void toSocket(java.net.Socket s)
Write this Request to the given Socket


fromSocket

public static HTTPReq fromSocket(java.net.Socket s)
Read a request from a Socket


fromInputStream

public static HTTPReq fromInputStream(java.io.InputStream inpt)
Read a Request from an InputStream


getBodyString

public java.lang.String getBodyString()
Return the Body of this Request


getHeaders

public Map<java.lang.String,java.lang.String> getHeaders()
Return the Headers of this Request as a Map


toString

public java.lang.String toString()
DGP method from Class PrintToString

Overrides:
toString in class java.lang.Object

getBody

public ident getBody()
Getter for field HTTPReq.body


getKeys

public List<MsgHead> getKeys()
Getter for field HTTPReq.keys


getHead

public HTTPHead getHead()
Getter for field HTTPReq.head