|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsimple.http.FilterRequest
public class FilterRequest
The FilterRequest
object is used so that the original
Request
object can be wrapped in a filtering proxy
object. This allows a ProtocolHandler
that interacts
with the Request
object in a concurrent environment.
This is also useful if any special behavior is need when a header
with special significance is added.
Field Summary | |
---|---|
protected Request |
req
This is the object that is being wrapped. |
Constructor Summary | |
---|---|
FilterRequest(Request req)
Constructor for FilterRequest allows the original
Request object to be wrapped so that adjustments
to the behavior of a Request object handed to a
specialized ProtocolHandler can be done simply. |
Method Summary | |
---|---|
void |
add(java.lang.String name,
int value)
This can be used to add a HTTP message header to this object. |
void |
add(java.lang.String name,
java.lang.String value)
This can be used to add a HTTP message header to this object. |
void |
addDate(java.lang.String name,
long date)
This is used as a convenience method for adding a header that needs to be parsed into a HTTP-date string. |
void |
clear()
This is used to clear all HTTP message headers from the message header. |
boolean |
contains(java.lang.String name)
This is used to see if there is a HTTP message header with the given name in this container. |
boolean |
contains(java.lang.String name,
java.lang.String value)
This is used to see if there is a HTTP message header with the given name in this container, if it exists this will check to see if the provided value exists. |
java.lang.Object |
getAttribute(java.lang.String name)
This is used as a shortcut for acquiring attributes for the request. |
Attributes |
getAttributes()
This can be used to retrieve certain attributes about this Request . |
int |
getContentLength()
This is a convenience method that can be used to determine the length of the message body. |
ContentType |
getContentType()
This is used to acquire the Content-Type for any HTTP message body that may be sent with the request. |
Cookie |
getCookie(java.lang.String name)
This method can be used to retrieve cookies from the header. |
long |
getDate(int off)
This can be used to get the value of the HTTP message header at the specified index. |
long |
getDate(java.lang.String name)
This can be used to get the date of the first message header that has the specified name. |
java.net.InetAddress |
getInetAddress()
Used to get the address from which this Request came
from. |
java.io.InputStream |
getInputStream()
This is used to read the content body. |
java.util.Locale |
getLanguage()
This provides Locale for the Accept-Language value. |
int |
getMajor()
This can be used to get the major number from a HTTP version. |
java.lang.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. |
java.lang.String |
getName(int off)
This is used to get the name value of the HTTP message header at the specified index. |
java.lang.String |
getParameter(java.lang.String name)
This is used to provide quick access to the parameters. |
Parameters |
getParameters()
This provides access to HTML form and query parameters. |
Path |
getPath()
This method is used to acquire the normalized path part of the HTTP request URI. |
Principal |
getPrincipal()
This is a convenience method that is used to retrieve the client authorized to this server. |
Session |
getSession()
This method is used to acquire a Session for the
request. |
State |
getState()
The State represents the collection of cookies
sent with this HTTP request. |
java.lang.String |
getURI()
This can be used to get the URI specified for this HTTP request. |
java.lang.String |
getValue(int off)
This is used to get the date value of the HTTP message header at the specified index. |
java.lang.String |
getValue(java.lang.String name)
This can be used to get the value of the first message header that has the specified name. |
java.lang.String[] |
getValues(java.lang.String name)
This can be used to get the values of HTTP message headers that have the specified name. |
int |
headerCount()
This can be used to determine how many HTTP message headers this object contains. |
int |
indexOf(java.lang.String name)
This can be used to find the first occurrence of the specified HTTP message header. |
int |
indexOf(java.lang.String name,
int from)
This can be used to find the first occurrence of the specified HTTP message header from a given index. |
boolean |
isKeepAlive()
This is a convenience method that is used to determine whether or not this message has the Connection: close
header. |
void |
remove(int off)
This can be used to remove the HTTP message header at the specified index. |
void |
removeAll(java.lang.String name)
This can be used to remove all HTTP message headers with the specified name. |
void |
set(java.lang.String name,
int value)
This can be used to set a HTTP message header to this object. |
void |
set(java.lang.String name,
java.lang.String value)
This can be used to set a HTTP message header to this object. |
void |
setDate(java.lang.String name,
long date)
This is used as a convenience method for setting a header that needs to be parsed into a HTTP-date string. |
void |
setMajor(int major)
This can be used to specify the major version for the HTTP request. |
void |
setMethod(java.lang.String method)
This is used to set the method for this HTTP request object. |
void |
setMinor(int minor)
This can be used to specify the minor version for the HTTP request. |
void |
setURI(java.lang.String target)
This can be used to set the URI for this HTTP request. |
java.lang.String |
toString()
This method is used so that the original HTTP header can be reconstructed This returns a String that
contains each header formatted according to the HTTP/1.1
header format. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Request req
Constructor Detail |
---|
public FilterRequest(Request req)
FilterRequest
allows the original
Request
object to be wrapped so that adjustments
to the behavior of a Request
object handed to a
specialized ProtocolHandler
can be done simply.
req
- the Request
object being wrappedMethod Detail |
---|
public java.lang.String getURI()
setURI
.
getURI
in interface RequestLine
public void setURI(java.lang.String target)
getURI
will return the String entered
which can be a full HTTP URL or a relative path URL.
setURI
in interface RequestLine
target
- the URI that this HTTP request is to usepublic java.lang.String getMethod()
getMethod
in interface RequestLine
public void setMethod(java.lang.String method)
setMethod
in interface RequestLine
method
- the desired method for thispublic int getMajor()
getMajor
in interface RequestLine
public void setMajor(int major)
setMajor
in interface RequestLine
major
- this is the major number desiredpublic int getMinor()
getMinor
in interface RequestLine
public void setMinor(int minor)
setMinor
in interface RequestLine
minor
- this is the minor number desiredpublic int headerCount()
headerCount
represents
the number of individual HTTP message headers that this has.
headerCount
in interface GenericHeader
public int indexOf(java.lang.String name)
indexOf
in interface GenericHeader
name
- name of the HTTP message header being searched for
public int indexOf(java.lang.String name, int from)
indexOf
in interface GenericHeader
name
- name of the HTTP message header being searched forfrom
- the index from which the search will start
public void add(java.lang.String name, java.lang.String value)
indexOf
in combination with the get methods.
add
in interface GenericHeader
name
- the name of the HTTP message header to be addedvalue
- the value the HTTP message header will havepublic void set(java.lang.String name, java.lang.String value)
indexOf
in combination with the get methods.
This will perform a removeAll
using the issued
header name before the header value is set.
set
in interface GenericHeader
name
- the name of the HTTP message header to be addedvalue
- the value the HTTP message header will havepublic void add(java.lang.String name, int value)
indexOf
in combination with the get methods.
add
in interface GenericHeader
name
- the name of the HTTP message header to be addedvalue
- the value the HTTP message header will havepublic void set(java.lang.String name, int value)
indexOf
in combination with the get methods.
This will perform a removeAll
using the issued
header name before the header value is set.
set
in interface GenericHeader
name
- the name of the HTTP message header to be addedvalue
- the value the HTTP message header will havepublic void addDate(java.lang.String name, long date)
addDate
in interface GenericHeader
name
- the name of the HTTP message header to be addeddate
- the value the HTTP message header will have when
parsed into RFC 1123 formatpublic void setDate(java.lang.String name, long date)
removeAll
using the issued
header name before the header value is set.
setDate
in interface GenericHeader
name
- the name of the HTTP message header to be addeddate
- the value the HTTP message header will have when
parsed into RFC 1123 formatpublic void remove(int off)
indexOf
method previous to this. If the
index specified is not valid then an
IndexOutOfBoundsException
may be thrown.
remove
in interface GenericHeader
off
- index of the HTTP message header to be removedpublic void removeAll(java.lang.String name)
removeAll
in interface GenericHeader
name
- name of the message headers to be removedpublic java.lang.String getValue(int off)
getValue
in interface GenericHeader
off
- the offset of the HTTP message header value
public java.lang.String getName(int off)
getValue(int)
method so that the contents of the
HTTP message header can be fully examined.
getName
in interface GenericHeader
off
- the offset of the HTTP message header name value
public long getDate(int off)
getDate
in interface GenericHeader
off
- the offset of the date HTTP message header value
public java.lang.String getValue(java.lang.String name)
indexOf
methods. This returns null if theres
not a HTTP message header.
getValue
in interface GenericHeader
name
- the HTTP message header to get the value from
public java.lang.String[] getValues(java.lang.String name)
indexOf
methods.
This will return an empty array if there are no headers of
the specified name within this list.
getValues
in interface GenericHeader
name
- the name of the headers that are to be retrieved
public long getDate(java.lang.String name)
indexOf
methods. This returns -1 if theres not a
HTTP message header.
getDate
in interface GenericHeader
name
- the HTTP message header to get the value from
public java.io.InputStream getInputStream() throws java.io.IOException
InputStream
can be determined
by the getContentLength
method. If the data sent by
the client is chunked then it is decoded, any footers sent
are ignored as they provide optional meta-data, see RFC 2616
section 3.6. The InputStream
must be
so that multiple threads can use the stream.
getInputStream
in interface Request
InputStream
containing the bytes
java.io.IOException
- thrown if there is an I/O errorpublic Parameters getParameters() throws java.io.IOException
InputStream
. If the data cannot be read
from the stream then an IOException
is thrown.
If the data on the stream is not of the correct MIME type then
an empty parameters object is returned. The MIME type for the
parameters is application/x-www-form-urlenoded
.
getParameters
in interface Request
java.io.IOException
- thrown if there is an I/O problempublic java.lang.String getParameter(java.lang.String name) throws java.io.IOException
Parameters
object.
This basically acquires the parameters object and invokes
the getParameters
method with the given name.
getParameter
in interface Request
name
- this is the name of the parameter value
java.io.IOException
- thrown if there is an I/O problempublic Path getPath()
Path
object
is read only, so changes will not affect the request header.
getPath
in interface Request
public ContentType getContentType()
contains
invocation to see
if the Content-Type header is in the HTTP header. The MIME
type is returned is a ContentType
object.
getContentType
in interface Request
public java.util.Locale getLanguage()
Locale
for the Accept-Language value.
This returns the first language preference from the header. If
the set of values are required the LanguageParser
from the simple.util.parse
package can be used.
If the header does not exist this will return the default
Locale
from Local.getDefault
.
getLanguage
in interface Request
Locale
preference of the clientpublic Cookie getCookie(java.lang.String name)
getState
method and from the State
invoke get
using the specified name.
getCookie
in interface Request
name
- this is the name of the cookie to be retrieved
simple.util.net.Cookie
object
to to represent the cookie of that name within the headerpublic State getState()
State
represents the collection of cookies
sent with this HTTP request. This represents the cookie state
established between the server and client using either domain
of path values see RFC 2109, HTTP State Management Mechanism.
The state is shared with the Response
which
will write each cookie set in the state as a Set-Cookie value
once the response has committed. This enables simple
management of state with the browser by using the state.
getState
in interface Request
State
which represents
the state maintained with the client applicationpublic Principal getPrincipal()
simple.util.net.Principal
that
identifies the client without having to decode the header.
getPrincipal
in interface Request
public Attributes getAttributes()
Request
. The Attributes
contains
certain properties about the Request
. For
example if this Request
came over a secure
line then there may be security attributes.
getAttributes
in interface Request
Request
objectpublic java.lang.Object getAttribute(java.lang.String name)
Attributes
in order to retrieve the attribute directly from that object.
The attributes contain data specific to the request.
getAttribute
in interface Request
name
- this is the name of the attribute to acquire
public Session getSession()
Session
for the
request. The object retrieved provides a container for data
associated to the connected client. This allows the request
to perform more complex operations based on knowledge that is
built up through a series of requests. The session is known
to the system using a Cookie
, which contains
the session reference. This cookie value should not be
modified as it used to reference the active session object.
getSession
in interface Request
Session
objectpublic java.net.InetAddress getInetAddress()
Request
came
from. This information can be retrieved from Attributes
object using the getAttributes
method. This can be
used to log HTTP requests for the server. This can also provide
security, where requests from specific locations are denied.
getInetAddress
in interface Request
Request
came frompublic 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 Request
public int getContentLength()
Content-Length
header, if it does then the
length can be determined. This will return a -1 if there is
no length.
getContentLength
in interface Request
public boolean contains(java.lang.String name)
contains
in interface GenericHeader
name
- the HTTP message header to get the value from
public boolean contains(java.lang.String name, java.lang.String value)
contains
in interface GenericHeader
name
- the HTTP message header to get the value fromvalue
- this value to find within the HTTP value
public void clear()
headerCount
is zero after this method is
invoked, this is a convenience method.
clear
in interface GenericHeader
public java.lang.String toString()
String
that
contains each header formatted according to the HTTP/1.1
header format. The header will contain the request line
followed by each header and ended with the CRLF.
toString
in interface Request
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |