public interface Request extends RequestHeader
Request
is used to provide an interface to the
HTTP entity body and message header. This provides methods that
allow the entity body to be acquired as a stream, string, or if
the message is a multipart encoded body, then the individual
parts of the request body can be acquired.
This can also maintain data during the request lifecycle as well
as the session lifecycle. A Session
is made available
for convenience. It provides a means for the services to associate
data with a given client session, which can be retrieved when
there are subsequent requests sent to the server.
It is important to note that the entity body can be read multiple
times from the request. Calling getInputStream
will
start reading from the first byte in the body regardless of the
number of times it is called. This allows POST parameters as well
as multipart bodies to be read from the stream if desired.
Modifier and Type | Method and Description |
---|---|
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.
|
InputStream |
getInputStream()
This is used to read the content body.
|
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. |
long |
getRequestTime()
This is the time in milliseconds when the request was first
read from the underlying socket.
|
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.
|
getContentLength, getContentType, getCookie, getCookies, getDate, getHeader, getInteger, getLocales, getNames, getValue, getValue, getValues, toString
getAddress, getMajor, getMethod, getMinor, getPath, getQuery, getTarget
boolean isSecure()
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.long getRequestTime()
Channel getChannel()
Certificate getClientCertificate()
InetSocketAddress getClientAddress()
Map getAttributes()
Object getAttribute(Object key)
Map
in order to retrieve the attribute directly from that object.
The attributes contain data specific to the response.key
- this is the key of the attribute to acquireString getParameter(String name)
Form
object.
This basically acquires the parameters object and invokes
the getParameters
method with the given name.name
- this is the name of the parameter valuePart 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.name
- this is the name of the part object to acquireList<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.String getContent() throws IOException
IOException
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.IOException
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.IOException
Copyright © 2022. All rights reserved.