org.xlightweb
Class PostRequest

Package class diagram package PostRequest
java.lang.Object
  extended by org.xlightweb.Part
      extended by org.xlightweb.HttpRequest
          extended by org.xlightweb.PostRequest
All Implemented Interfaces:
IHeader, IHttpMessage, IHttpRequest, IPart
Direct Known Subclasses:
FormURLEncodedRequest

public class PostRequest
extends HttpRequest

POST request


Field Summary
 
Fields inherited from interface org.xlightweb.IHttpMessage
CONNECT_METHOD, DEFAULT_ENCODING, DEFAULT_ENCODING_KEY, DELETE_METHOD, GET_METHOD, HEAD_METHOD, OPTIONS_METHOD, POST_METHOD, PUT_METHOD, TRACE_METHOD
 
Constructor Summary
PostRequest(String url)
          constructor
PostRequest(String url, File file)
          constructor
PostRequest(String url, File file, boolean compress)
          constructor
PostRequest(String url, NameValuePair... formParameters)
          constructor PostRequest req = new PostRequest(urlBase + "/login", new NameValuePair("name", "ItsMe")); ...
PostRequest(String url, String contentType)
          constructor
PostRequest(String url, String[] formParameters)
          constructor

Example: PostRequest req = new PostRequest(urlBase + "/login", new String[] { "name=ItsMe", "pwd=VerySecret" })); ...
PostRequest(String url, String contentType, byte[] body)
          constructor
PostRequest(String url, String contentType, byte[] body, boolean compress)
          constructor
PostRequest(String url, String contentType, ByteBuffer[] body)
          constructor
PostRequest(String url, String contentType, ByteBuffer[] body, boolean compress)
          constructor
PostRequest(String url, String contentType, String body)
          constructor
PostRequest(String url, String contentType, String body, boolean compress)
          constructor
PostRequest(String url, String contentType, String encoding, String body)
          constructor
PostRequest(String url, String contentType, String encoding, String body, boolean compress)
          constructor
 
Method Summary
 Object getAttribute(String name)
          Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.
 Enumeration getAttributeNames()
          Returns an Enumeration containing the names of the attributes available to this message.
 Set<String> getAttributeNameSet()
          Returns an Set containing the names of the attributes available to this messaget.
 int getContentLength()
          Returns the length, in bytes, of the message body and made available by the input stream, or -1 if the length is not known.
 IHttpMessageHeader getMessageHeader()
          returns the message header
 void removeHopByHopHeaders()
          removes all hop-by-hop headers without Transfer-Encoding if set to chunked
 void setAttribute(String name, Object o)
          Stores an attribute in this header.
 void setContentLength(int length)
          sets the content length in bytes
 
Methods inherited from class org.xlightweb.HttpRequest
addMatrixParameter, addParameter, getAccept, getBooleanParameter, getBooleanParameter, getContextPath, getDoubleParameter, getDoubleParameter, getFloatParameter, getFloatParameter, getHost, getIntParameter, getIntParameter, getLongParameter, getLongParameter, getMatrixParameter, getMatrixParameterNameSet, getMatrixParameterValues, getMethod, getParameter, getParameter, getParameterNames, getParameterNameSet, getParameterValues, getPathInfo, getPathInfo, getProtocol, getProtocolVersion, getQueryString, getRemoteAddr, getRemoteHost, getRemotePort, getRequestHandlerPath, getRequestHeader, getRequestURI, getRequestUrl, getRequiredBooleanParameter, getRequiredDoubleParameter, getRequiredFloatParameter, getRequiredIntParameter, getRequiredLongParameter, getRequiredStringParameter, getScheme, getServerName, getServerPort, getUserAgent, isSecure, removeMatrixParameter, removeParameter, setContextPath, setHost, setMatrixParameter, setMethod, setParameter, setRequestHandlerPath, setRequestURI, setRequestUrl, setUserAgent
 
Methods inherited from class org.xlightweb.Part
addHeader, addHeaderLine, addHeaderlines, containsHeader, getBlockingBody, getBody, getCharacterEncoding, getContentType, getDisposition, getDispositionParam, getDispositionType, getHeader, getHeaderList, getHeaderNames, getHeaderNameSet, getHeaders, getNonBlockingBody, getPartHeader, getTransferEncoding, hasBody, removeHeader, setContentType, setHeader, setTransferEncoding, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xlightweb.IHttpMessage
getAttribute, getAttributeNames, getAttributeNameSet, getCharacterEncoding, getContentLength, getContentType, getMessageHeader, getTransferEncoding, removeHopByHopHeaders, setAttribute, setContentLength, setContentType, setTransferEncoding
 
Methods inherited from interface org.xlightweb.IPart
getBlockingBody, getBody, getNonBlockingBody, getPartHeader, hasBody
 
Methods inherited from interface org.xlightweb.IHeader
addHeader, addHeaderLine, addHeaderlines, containsHeader, getDisposition, getDispositionParam, getDispositionType, getHeader, getHeaderList, getHeaderNames, getHeaderNameSet, getHeaders, removeHeader, setHeader
 

Constructor Detail

PostRequest

public PostRequest(String url)
            throws MalformedURLException
constructor

Parameters:
url - the url string
Throws:
MalformedURLException - if the url is malformed

PostRequest

public PostRequest(String url,
                   String contentType)
            throws IOException,
                   MalformedURLException
constructor

Parameters:
url - the url string
contentType - the content type
Throws:
MalformedURLException - if the url is malformed
IOException - if an exception occurs

PostRequest

public PostRequest(String url,
                   String contentType,
                   String body)
            throws IOException,
                   MalformedURLException
constructor

Parameters:
url - the url string
contentType - the content type
body - the body
Throws:
MalformedURLException - if the url is malformed
IOException - if an exception occurs

PostRequest

public PostRequest(String url,
                   String contentType,
                   String body,
                   boolean compress)
            throws IOException,
                   MalformedURLException
constructor

Parameters:
url - the url string
contentType - the content type
body - the body
compress - true, if the body should be compressed
Throws:
MalformedURLException - if the url is malformed
IOException - if an exception occurs

PostRequest

public PostRequest(String url,
                   File file)
            throws IOException,
                   MalformedURLException
constructor

Parameters:
url - the url string
file - the file
Throws:
MalformedURLException - if the url is malformed
IOException - if an exception occurs

PostRequest

public PostRequest(String url,
                   File file,
                   boolean compress)
            throws IOException,
                   MalformedURLException
constructor

Parameters:
url - the url string
file - the file
compress - true, if the body should be compressed
Throws:
MalformedURLException - if the url is malformed
IOException - if an exception occurs

PostRequest

public PostRequest(String url,
                   String contentType,
                   String encoding,
                   String body)
            throws IOException,
                   MalformedURLException
constructor

Parameters:
url - the url string
encoding - the encoding
contentType - the content type
body - the body
Throws:
MalformedURLException - if the url is malformed
IOException - if an exception occurs

PostRequest

public PostRequest(String url,
                   String contentType,
                   String encoding,
                   String body,
                   boolean compress)
            throws IOException,
                   MalformedURLException
constructor

Parameters:
url - the url string
encoding - the encoding
contentType - the content type
body - the body
compress - true, if the body should be compressed
Throws:
MalformedURLException - if the url is malformed
IOException - if an exception occurs

PostRequest

public PostRequest(String url,
                   String contentType,
                   byte[] body)
            throws IOException,
                   MalformedURLException
constructor

Parameters:
url - the url string
contentType - the content type
body - the body
Throws:
MalformedURLException - if the url is malformed
IOException - if an exception occurs

PostRequest

public PostRequest(String url,
                   String contentType,
                   byte[] body,
                   boolean compress)
            throws IOException,
                   MalformedURLException
constructor

Parameters:
url - the url string
contentType - the content type
body - the body
compress - true, if the body should be compressed
Throws:
MalformedURLException - if the url is malformed
IOException - if an exception occurs

PostRequest

public PostRequest(String url,
                   String contentType,
                   ByteBuffer[] body)
            throws IOException,
                   MalformedURLException
constructor

Parameters:
url - the url string
contentType - the content type
body - the body
Throws:
MalformedURLException - if the url is malformed
IOException - if an exception occurs

PostRequest

public PostRequest(String url,
                   String contentType,
                   ByteBuffer[] body,
                   boolean compress)
            throws IOException,
                   MalformedURLException
constructor

Parameters:
url - the url string
contentType - the content type
body - the body
compress - true, if the body should be compressed
Throws:
MalformedURLException - if the url is malformed
IOException - if an exception occurs

PostRequest

public PostRequest(String url,
                   NameValuePair... formParameters)
            throws IOException,
                   MalformedURLException
constructor
 PostRequest req = new PostRequest(urlBase + "/login", new NameValuePair("name", "ItsMe"));
 ...
 

Parameters:
url - the url string
formParameters - an Array of FORM parameter
Throws:
MalformedURLException - if the url is malformed
IOException - if an exception occurs

PostRequest

public PostRequest(String url,
                   String[] formParameters)
            throws IOException,
                   MalformedURLException
constructor

Example:
 PostRequest req = new PostRequest(urlBase + "/login", new String[] { "name=ItsMe", "pwd=VerySecret" }));
 ...
 

Parameters:
url - the url string
formParameters - array of FORM parameters formatted as =
Throws:
MalformedURLException - if the url is malformed
IOException - if an exception occurs
Method Detail

getMessageHeader

public final IHttpMessageHeader getMessageHeader()
returns the message header

Specified by:
getMessageHeader in interface IHttpMessage
Returns:
the message header

setAttribute

public final void setAttribute(String name,
                               Object o)
Stores an attribute in this header. Attributes are reset between messages.

Attribute names should follow the same conventions as package names.

Specified by:
setAttribute in interface IHttpMessage
Parameters:
name - a String specifying the name of the attribute
o - the Object to be stored

getAttribute

public final Object getAttribute(String name)
Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.

Attribute names should follow the same conventions as package names.

Specified by:
getAttribute in interface IHttpMessage
Parameters:
name - a String specifying the name of the attribute
Returns:
an Object containing the value of the attribute, or null if the attribute does not exist

getAttributeNames

public final Enumeration getAttributeNames()
Returns an Enumeration containing the names of the attributes available to this message. This method returns an empty Enumeration if the message has no attributes available to it.

Specified by:
getAttributeNames in interface IHttpMessage
Returns:
an Enumeration of strings containing the names of the message's attributes

getAttributeNameSet

public final Set<String> getAttributeNameSet()
Returns an Set containing the names of the attributes available to this messaget. This method returns an empty Set if the request has no attributes available to it.

Specified by:
getAttributeNameSet in interface IHttpMessage
Returns:
an Set of strings containing the names of the message's attributes

getContentLength

public final int getContentLength()
Returns the length, in bytes, of the message body and made available by the input stream, or -1 if the length is not known.

Specified by:
getContentLength in interface IHttpMessage
Returns:
an integer containing the length of the message body or -1 if the length is not known

setContentLength

public final void setContentLength(int length)
sets the content length in bytes

Specified by:
setContentLength in interface IHttpMessage
Parameters:
length - the content length in bytes

removeHopByHopHeaders

public final void removeHopByHopHeaders()
removes all hop-by-hop headers without Transfer-Encoding if set to chunked

Specified by:
removeHopByHopHeaders in interface IHttpMessage