|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.simpleframework.http.RequestWrapper
public class RequestWrapper
The RequestWrapper object is used so that the original
Request object can be wrapped in a filtering proxy
object. This allows a Container that interacts with
a modified request object. To add functionality to the request it
can be wrapped in a subclass of this and the overridden methods
can provide modified functionality to the standard request.
| Field Summary | |
|---|---|
protected Request |
request
This is the request instance that is being wrapped. |
| Constructor Summary | |
|---|---|
RequestWrapper(Request request)
Constructor for RequestWrapper object. |
|
| Method Summary | |
|---|---|
Address |
getAddress()
This is used to acquire the address from the request line. |
Object |
getAttribute(Object key)
This is used as a shortcut for acquiring attributes for the response. |
Map |
getAttributes()
This can be used to retrieve the response attributes. |
ReadableByteChannel |
getByteChannel()
This is used to read the content body. |
Channel |
getChannel()
This provides the underlying channel for the request. |
InetSocketAddress |
getClientAddress()
This is used to acquire the remote client address. |
Certificate |
getClientCertificate()
This is used to acquire the SSL certificate used when the server is using a HTTPS connection. |
String |
getContent()
This is used to get the content body. |
long |
getContentLength()
This is a convenience method that can be used to determine the length of the message body. |
ContentType |
getContentType()
This is a convenience method that can be used to determine the content type of the message body. |
Cookie |
getCookie(String name)
This is used to acquire a cookie usiing the name of that cookie. |
List<Cookie> |
getCookies()
This is used to acquire all cookies that were sent in the header. |
long |
getDate(String name)
This can be used to get the date of the first message header that has the specified name. |
CharSequence |
getHeader()
This method returns a CharSequence holding the header
consumed for the request. |
InputStream |
getInputStream()
This is used to read the content body. |
int |
getInteger(String name)
This can be used to get the integer of the first message header that has the specified name. |
List<Locale> |
getLocales()
This is used to acquire the locales from the request header. |
int |
getMajor()
This can be used to get the major number from a HTTP version. |
String |
getMethod()
This can be used to get the HTTP method for this request. |
int |
getMinor()
This can be used to get the major number from a HTTP version. |
List<String> |
getNames()
This method is used to get a List of the names
for the headers. |
String |
getParameter(String name)
This is used to provide quick access to the parameters. |
Part |
getPart(String name)
This method is used to acquire a Part from the
HTTP request using a known name for the part. |
List<Part> |
getParts()
This method is used to get all Part objects that
are associated with the request. |
Path |
getPath()
This is used to acquire the path as extracted from the HTTP request URI. |
Query |
getQuery()
This method is used to acquire the query part from the HTTP request URI target and a form post if it exists. |
long |
getRequestTime()
This is the time in milliseconds when the request was first read from the underlying socket. |
String |
getTarget()
This can be used to get the URI specified for this HTTP request. |
String |
getValue(String name)
This can be used to get the value of the first message header that has the specified name. |
String |
getValue(String name,
int index)
This can be used to get the value of the first message header that has the specified name. |
List<String> |
getValues(String name)
This can be used to get the values of HTTP message headers that have the specified name. |
boolean |
isKeepAlive()
This is a convenience method that is used to determine whether or not this message has the Connection: close
header. |
boolean |
isSecure()
This is used to determine if the request has been transferred over a secure connection. |
String |
toString()
This method returns a string representing the header that was consumed for this request. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected Request request
| Constructor Detail |
|---|
public RequestWrapper(Request request)
RequestWrapper object. This allows
the original Request object to be wrapped so that
adjustments to the behaviour of a request object handed to the
container can be provided by a subclass implementation.
request - the request object that is being wrapped| Method Detail |
|---|
public int getMajor()
getMajor in interface RequestLinepublic int getMinor()
getMinor in interface RequestLinepublic String getMethod()
getMethod in interface RequestLinepublic String getTarget()
getTarget in interface RequestLinepublic Address getAddress()
getAddress in interface RequestLinepublic Path getPath()
Path object that is provided by
this method is immutable, it represents the normalized path
only part from the request uniform resource identifier.
getPath in interface RequestLinepublic Query getQuery()
getQuery in interface RequestLinepublic List<String> getNames()
List of the names
for the headers. This will provide the original names for the
HTTP headers for the message. Modifications to the provided
list will not affect the header, the list is a simple copy.
getNames in interface RequestHeaderpublic int getInteger(String name)
getInteger in interface RequestHeadername - the HTTP message header to get the value from
public long getDate(String name)
getDate in interface RequestHeadername - the HTTP message header to get the value from
public Cookie getCookie(String name)
Cookie object. Otherwise this method will
return null. Each cookie object will contain the name, value
and path of the cookie as well as the optional domain part.
getCookie in interface RequestHeadername - this is the name of the cookie object to acquire
public List<Cookie> getCookies()
Cookie objects. Otherwise this method will an
empty list. Each cookie object will contain the name, value and
path of the cookie as well as the optional domain part.
getCookies in interface RequestHeaderpublic String getValue(String name)
getValue in interface RequestHeadername - the HTTP message header to get the value from
public String getValue(String name,
int index)
getValue in interface RequestHeadername - the HTTP message header to get the value fromindex - if there are multiple values this selects one
public List<String> getValues(String name)
substring and trim calls.
The tokens returned by this method are ordered according to there HTTP quality values, or "q" values, see RFC 2616 section 3.9. This also strips out the quality parameter from tokens returned. So "image/html; q=0.9" results in "image/html". If there are no "q" values present then order is by appearence.
The result from this is either the trimmed header value, that is, the header value with no leading or trailing whitespace or an array of trimmed tokens ordered with the most preferred in the lower indexes, so index 0 is has higest preference.
getValues in interface RequestHeadername - the name of the headers that are to be retrieved
public List<Locale> getLocales()
Accept-Language header.
This provides an indication as to the languages that the client
accepts. It provides the locales in preference order.
getLocales in interface RequestHeaderpublic ContentType getContentType()
Content-Type header, if there is then
this will parse that header and represent it as a typed object
which will expose the various parts of the HTTP header.
getContentType in interface RequestHeaderpublic long getContentLength()
Content-Length header, if it does then the
length can be determined, if not then this returns -1.
getContentLength in interface RequestHeaderpublic boolean isSecure()
isSecure in interface Requestpublic boolean isKeepAlive()
Connection: close
header. If the close token is present then this stream is not
a keep-alive connection. If this has no Connection
header then the keep-alive status is determined by the HTTP
version, that is, HTTP/1.1 is keep-alive by default, HTTP/1.0
is not keep-alive by default.
isKeepAlive in interface Requestpublic long getRequestTime()
getRequestTime in interface Requestpublic Channel getChannel()
getChannel in interface Requestpublic Certificate getClientCertificate()
getClientCertificate in interface Requestpublic Map getAttributes()
getAttributes in interface Requestpublic Object getAttribute(Object key)
Map
in order to retrieve the attribute directly from that object.
The attributes contain data specific to the response.
getAttribute in interface Requestkey - this is the key of the attribute to acquire
public InetSocketAddress getClientAddress()
getClientAddress in interface Requestpublic CharSequence getHeader()
CharSequence holding the header
consumed for the request. A character sequence is returned as it
can provide a much more efficient means of representing the header
data by just wrapping the consumed byte array.
getHeader in interface RequestHeader
public String getContent()
throws IOException
getContent in interface RequestIOException - signifies that there is an I/O problem
public InputStream getInputStream()
throws IOException
InputStream can be determined
by the getContentLength method. If the data sent by
the client is chunked then it is decoded, see RFC 2616 section
3.6. Also multipart data is available as Part objects
however the raw content of the multipart body is still available.
getInputStream in interface RequestException - signifies that there is an I/O problem
IOException
public ReadableByteChannel getByteChannel()
throws IOException
ReadableByteChannel can be
determined by the getContentLength method. If the
data sent by the client is chunked then it is decoded, see RFC
2616 section 3.6. This stream will never provide empty reads as
the content is internally buffered, so this can do a full read.
getByteChannel in interface RequestIOExceptionpublic String getParameter(String name)
Form object.
This basically acquires the parameters object and invokes
the getParameters method with the given name.
getParameter in interface Requestname - this is the name of the parameter valuepublic Part getPart(String name)
Part from the
HTTP request using a known name for the part. This is typically
used when there is a file upload with a multipart POST request.
All parts that are not files can be acquired as string values
from the attachment object.
getPart in interface Requestname - this is the name of the part object to acquire
public List<Part> getParts()
Part objects that
are associated with the request. Each attachment contains the
body and headers associated with it. If the request is not a
multipart POST request then this will return an empty list.
getParts in interface Requestpublic String toString()
toString in interface RequestHeadertoString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||