public interface Request extends MutableRegistry
Modifier and Type | Field and Description |
---|---|
static TypeToken<Request> |
TYPE
A type token for this type.
|
Modifier and Type | Method and Description |
---|---|
<O> Request |
add(Class<? super O> type,
O object)
Adds a registry entry that is available by the given type.
|
Request |
add(Object object)
Adds a registry entry.
|
<O> Request |
add(TypeToken<? super O> type,
O object)
Adds a registry entry that is available by the given type.
|
<O> Request |
addLazy(Class<O> type,
Supplier<? extends O> supplier)
Adds a lazily created entry to the registry.
|
<O> Request |
addLazy(TypeToken<O> type,
Supplier<? extends O> supplier)
Adds a lazily created entry to the registry.
|
Promise<TypedData> |
getBody()
The body of the request.
|
Promise<TypedData> |
getBody(Block onTooLarge)
The body of the request.
|
Promise<TypedData> |
getBody(long maxContentLength)
The body of the request allowing up to the provided size for the content.
|
Promise<TypedData> |
getBody(long maxContentLength,
Block onTooLarge)
The body of the request allowing up to the provided size for the content.
|
MediaType |
getContentType()
The type of the data as specified in the
"content-type" header. |
Set<Cookie> |
getCookies()
The cookies that were sent with the request.
|
Headers |
getHeaders()
The request headers.
|
HostAndPort |
getLocalAddress()
The address of the local network interface that received the request.
|
HttpMethod |
getMethod()
The method of the request.
|
String |
getPath()
The URI without the query string and leading forward slash.
|
String |
getProtocol()
The HTTP protocol of the request.
|
String |
getQuery()
The query string component of the request URI, without the "?".
|
MultiValueMap<String,String> |
getQueryParams()
TBD.
|
String |
getRawUri()
The raw URI of the request.
|
HostAndPort |
getRemoteAddress()
The address of the client that initiated the request.
|
Instant |
getTimestamp()
The timestamp for when this request was received.
|
String |
getUri()
The complete URI of the request (path + query string).
|
boolean |
isAjaxRequest()
A flag representing whether or not the request originated via AJAX.
|
String |
oneCookie(String name)
Returns the value of the cookie with the specified name if it was sent.
|
remove, remove
backedBy, builder, empty, first, first, get, get, getAll, getAll, join, maybeGet, maybeGet, of, single, single, single, singleLazy
with
HttpMethod getMethod()
String getProtocol()
String getRawUri()
This value may be an absolute URI or an absolute path.
String getUri()
This value is always absolute (i.e. begins with "/
").
String getQuery()
If the request does not contain a query component, an empty string will be returned.
String getPath()
MultiValueMap<String,String> getQueryParams()
Set<Cookie> getCookies()
An empty set will be returned if no cookies were sent.
@Nullable String oneCookie(String name)
If there is more than one cookie with this name, this method will throw an exception.
name
- The name of the cookie to get the value ofPromise<TypedData> getBody()
If this request does not have a body, a non null object is still returned but it effectively has no data.
If the transmitted content is larger than provided ServerConfig.getMaxContentLength()
, the given block will be invoked.
If the block completes successfully, the promise will be terminated.
If the block errors, the promise will carry the failure.
Promise<TypedData> getBody(Block onTooLarge)
If this request does not have a body, a non null object is still returned but it effectively has no data.
If the transmitted content is larger than provided maxContentLength
, the given block will be invoked.
If the block completes successfully, the promise will be terminated.
If the block errors, the promise will carry the failure.
onTooLarge
- the action to take if the request body exceeds the given maxContentLengthPromise<TypedData> getBody(long maxContentLength)
If this request does not have a body, a non null object is still returned but it effectively has no data.
If the transmitted content is larger than the provided maxContentLength
, an 413
client error will be issued.
maxContentLength
- the maximum number of bytes allowed for the request.Promise<TypedData> getBody(long maxContentLength, Block onTooLarge)
If this request does not have a body, a non null object is still returned but it effectively has no data.
If the transmitted content is larger than the provided maxContentLength
, the given block will be invoked.
If the block completes successfully, the promise will be terminated.
If the block errors, the promise will carry the failure.
maxContentLength
- the maximum number of bytes allowed for the request.onTooLarge
- the action to take if the request body exceeds the given maxContentLengthHeaders getHeaders()
MediaType getContentType()
"content-type"
header.
If no "content-type"
header is specified, an empty MediaType
is returned.
MediaType.isEmpty()
HostAndPort getRemoteAddress()
HostAndPort getLocalAddress()
boolean isAjaxRequest()
Instant getTimestamp()
<O> Request add(Class<? super O> type, O object)
add
in interface RegistrySpec
O
- the public type of the registry entrytype
- the public type of the registry entryobject
- the actual registry entry<O> Request add(TypeToken<? super O> type, O object)
add
in interface RegistrySpec
O
- the public type of the registry entrytype
- the public type of the registry entryobject
- the actual registry entryRequest add(Object object)
add
in interface RegistrySpec
object
- the object to add to the registry<O> Request addLazy(Class<O> type, Supplier<? extends O> supplier)
The supplier will be invoked exactly once, when a query is made to the registry of a compatible type of the given type.
addLazy
in interface RegistrySpec
O
- the public type of the registry entrytype
- the public type of the registry entrysupplier
- the supplier for creating the object when needed<O> Request addLazy(TypeToken<O> type, Supplier<? extends O> supplier)
The supplier will be invoked exactly once, when a query is made to the registry of a compatible type of the given type.
addLazy
in interface RegistrySpec
O
- the public type of the registry entrytype
- the public type of the registry entrysupplier
- the supplier for creating the object when needed