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

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

public class HTTPResp
extends java.lang.Object

Representation of HTTPResp


Nested Class Summary
static class HTTPResp.body
          Field Class for HTTPResp.body
static class HTTPResp.keys
          Field Class for HTTPResp.keys
static class HTTPResp.label
          Field Class for HTTPResp.label
static class HTTPResp.resp
          Field Class for HTTPResp.resp
static class HTTPResp.ver
          Field Class for HTTPResp.ver
 
Field Summary
static int ERROR
          Basic Response Numbers
static int OK
          Basic Response Numbers
static HTTPVer VER
          Typical HTTP Version
 
Constructor Summary
HTTPResp(HTTPVer ver, int resp, ident label, List<MsgHead> keys, ident body)
          Construct a(n) HTTPResp Instance
 
Method Summary
static HTTPResp create(int resp, java.lang.String desc, List<MsgHead> hds, java.lang.String body)
          Create a response with the given number, description, headers, and body
 boolean equals(java.lang.Object o)
          Is the given object Equal to this HTTPResp?
static HTTPResp error()
          Create an (empty) Error Response
static HTTPResp error(java.lang.String body)
          Create an Error Response with a Body
static HTTPResp fromInputStream(java.io.InputStream inpt)
          Read a Response from an Input Stream
static HTTPResp fromSocket(java.net.Socket s)
          Read a Response from a Socket
 ident getBody()
          Getter for field HTTPResp.body
 java.lang.String getBodyString()
          Get the body of this Response
 Map<java.lang.String,java.lang.String> getHeaders()
          Return the headers (key/value Map) of this Response
 List<MsgHead> getKeys()
          Getter for field HTTPResp.keys
 ident getLabel()
          Getter for field HTTPResp.label
 int getResp()
          Getter for field HTTPResp.resp
 HTTPVer getVer()
          Getter for field HTTPResp.ver
static HTTPResp htmlError(java.lang.String body)
          Create an HTML Error Response with a Body
static HTTPResp htmlResponse(java.lang.String text)
          Create an HTML Response
 boolean isError()
          Is this Response an Error?
 boolean isOK()
          Is this Response OK?
static HTTPResp ok(java.lang.String type, java.lang.String body)
          Create an OK Response with the given Content-Type/Body
static HTTPResp textResponse(java.lang.String text)
          Create a Plain Text Response
 void toSocket(java.net.Socket s)
          Write a Response to a Socket
 java.lang.String toString()
          DGP method from Class PrintToString
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OK

public static final int OK
Basic Response Numbers

See Also:
Constant Field Values

ERROR

public static final int ERROR
Basic Response Numbers

See Also:
Constant Field Values

VER

public static final HTTPVer VER
Typical HTTP Version

Constructor Detail

HTTPResp

public HTTPResp(HTTPVer ver,
                int resp,
                ident label,
                List<MsgHead> keys,
                ident body)
Construct a(n) HTTPResp Instance

Method Detail

equals

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

Overrides:
equals in class java.lang.Object

create

public static HTTPResp create(int resp,
                              java.lang.String desc,
                              List<MsgHead> hds,
                              java.lang.String body)
Create a response with the given number, description, headers, and body


ok

public static HTTPResp ok(java.lang.String type,
                          java.lang.String body)
Create an OK Response with the given Content-Type/Body


error

public static HTTPResp error()
Create an (empty) Error Response


error

public static HTTPResp error(java.lang.String body)
Create an Error Response with a Body


htmlError

public static HTTPResp htmlError(java.lang.String body)
Create an HTML Error Response with a Body


textResponse

public static HTTPResp textResponse(java.lang.String text)
Create a Plain Text Response


htmlResponse

public static HTTPResp htmlResponse(java.lang.String text)
Create an HTML Response


isOK

public boolean isOK()
Is this Response OK?


isError

public boolean isError()
Is this Response an Error?


toSocket

public void toSocket(java.net.Socket s)
Write a Response to a Socket


fromSocket

public static HTTPResp fromSocket(java.net.Socket s)
Read a Response from a Socket


fromInputStream

public static HTTPResp fromInputStream(java.io.InputStream inpt)
Read a Response from an Input Stream


getBodyString

public java.lang.String getBodyString()
Get the body of this Response


getHeaders

public Map<java.lang.String,java.lang.String> getHeaders()
Return the headers (key/value Map) of this Response


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 HTTPResp.body


getKeys

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


getLabel

public ident getLabel()
Getter for field HTTPResp.label


getResp

public int getResp()
Getter for field HTTPResp.resp


getVer

public HTTPVer getVer()
Getter for field HTTPResp.ver