public class DefaultServerWebExchange extends java.lang.Object implements ServerWebExchange
ServerWebExchange
.ServerWebExchange.Builder
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,java.lang.Object> |
attributes |
private static <any> |
EMPTY_FORM_DATA |
private static ResolvableType |
FORM_DATA_VALUE_TYPE |
private static FormHttpMessageReader |
FORM_READER |
private <any> |
formDataMono |
private boolean |
notModified |
private ServerHttpRequest |
request |
private <any> |
requestParamsMono |
private ServerHttpResponse |
response |
private static java.util.List<HttpMethod> |
SAFE_METHODS |
private <any> |
sessionMono |
Constructor and Description |
---|
DefaultServerWebExchange(ServerHttpRequest request,
ServerHttpResponse response)
Constructor with a request and response only.
|
DefaultServerWebExchange(ServerHttpRequest request,
ServerHttpResponse response,
WebSessionManager sessionManager)
Alternate constructor with a WebSessionManager parameter.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkNotModified(java.time.Instant lastModified)
An overloaded variant of
ServerWebExchange.checkNotModified(String, Instant) with
a last-modified timestamp only. |
boolean |
checkNotModified(java.lang.String etag)
An overloaded variant of
ServerWebExchange.checkNotModified(String, Instant) with
an ETag (entity tag) value only. |
boolean |
checkNotModified(java.lang.String etag,
java.time.Instant lastModified)
Check whether the requested resource has been modified given the supplied
ETag (entity tag) and last-modified timestamp as determined by
the application. |
<T> java.util.Optional<T> |
getAttribute(java.lang.String name)
Return the request attribute value if present.
|
java.util.Map<java.lang.String,java.lang.Object> |
getAttributes()
Return a mutable map of request attributes for the current exchange.
|
<any> |
getFormData()
Return the form data from the body of the request if the Content-Type is
"application/x-www-form-urlencoded" or an empty map. |
<T extends java.security.Principal> |
getPrincipal()
Return the authenticated user for the request, if any.
|
ServerHttpRequest |
getRequest()
Return the current HTTP request.
|
private HttpHeaders |
getRequestHeaders() |
<any> |
getRequestParams()
Return a combined map that represents both
ServerHttpRequest.getQueryParams() and ServerWebExchange.getFormData()
or an empty map. |
ServerHttpResponse |
getResponse()
Return the current HTTP response.
|
private HttpHeaders |
getResponseHeaders() |
<any> |
getSession()
Return the web session for the current request.
|
private static <any> |
initFormData(ServerHttpRequest request) |
private static <any> |
initRequestParams(ServerHttpRequest request,
<any> formDataMono) |
boolean |
isNotModified()
Returns
true if the one of the checkNotModified methods
in this contract were used and they returned true. |
private java.lang.String |
padEtagIfNecessary(java.lang.String etag) |
private boolean |
validateIfModifiedSince(java.time.Instant lastModified) |
private boolean |
validateIfNoneMatch(java.lang.String etag) |
private boolean |
validateIfUnmodifiedSince(java.time.Instant lastModified) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
mutate
private static final java.util.List<HttpMethod> SAFE_METHODS
private static final FormHttpMessageReader FORM_READER
private static final ResolvableType FORM_DATA_VALUE_TYPE
private static final <any> EMPTY_FORM_DATA
private final ServerHttpRequest request
private final ServerHttpResponse response
private final java.util.Map<java.lang.String,java.lang.Object> attributes
private final <any> sessionMono
private final <any> formDataMono
private final <any> requestParamsMono
private volatile boolean notModified
public DefaultServerWebExchange(ServerHttpRequest request, ServerHttpResponse response)
DefaultWebSessionManager
.public DefaultServerWebExchange(ServerHttpRequest request, ServerHttpResponse response, WebSessionManager sessionManager)
private static <any> initFormData(ServerHttpRequest request)
private static <any> initRequestParams(ServerHttpRequest request, <any> formDataMono)
public ServerHttpRequest getRequest()
ServerWebExchange
getRequest
in interface ServerWebExchange
private HttpHeaders getRequestHeaders()
public ServerHttpResponse getResponse()
ServerWebExchange
getResponse
in interface ServerWebExchange
private HttpHeaders getResponseHeaders()
public java.util.Map<java.lang.String,java.lang.Object> getAttributes()
ServerWebExchange
getAttributes
in interface ServerWebExchange
public <T> java.util.Optional<T> getAttribute(java.lang.String name)
ServerWebExchange
getAttribute
in interface ServerWebExchange
T
- the attribute typename
- the attribute namepublic <any> getSession()
ServerWebExchange
WebSession
for more details.getSession
in interface ServerWebExchange
public <T extends java.security.Principal> <any> getPrincipal()
ServerWebExchange
getPrincipal
in interface ServerWebExchange
public <any> getFormData()
ServerWebExchange
"application/x-www-form-urlencoded"
or an empty map.getFormData
in interface ServerWebExchange
public <any> getRequestParams()
ServerWebExchange
ServerHttpRequest.getQueryParams()
and ServerWebExchange.getFormData()
or an empty map.getRequestParams
in interface ServerWebExchange
public boolean isNotModified()
ServerWebExchange
true
if the one of the checkNotModified
methods
in this contract were used and they returned true.isNotModified
in interface ServerWebExchange
public boolean checkNotModified(java.time.Instant lastModified)
ServerWebExchange
ServerWebExchange.checkNotModified(String, Instant)
with
a last-modified timestamp only.checkNotModified
in interface ServerWebExchange
lastModified
- the last-modified timepublic boolean checkNotModified(java.lang.String etag)
ServerWebExchange
ServerWebExchange.checkNotModified(String, Instant)
with
an ETag
(entity tag) value only.checkNotModified
in interface ServerWebExchange
etag
- the entity tag for the underlying resource.public boolean checkNotModified(java.lang.String etag, java.time.Instant lastModified)
ServerWebExchange
ETag
(entity tag) and last-modified timestamp as determined by
the application. Also transparently prepares the response, setting HTTP
status, and adding "ETag" and "Last-Modified" headers when applicable.
This method works with conditional GET/HEAD requests as well as with
conditional POST/PUT/DELETE requests.
Note: The HTTP specification recommends setting both
ETag and Last-Modified values, but you can also use
#checkNotModified(String)
or
ServerWebExchange.checkNotModified(Instant)
.
checkNotModified
in interface ServerWebExchange
etag
- the entity tag that the application determined for the
underlying resource. This parameter will be padded with quotes (")
if necessary.lastModified
- the last-modified timestamp that the application
determined for the underlying resourceprivate boolean validateIfUnmodifiedSince(java.time.Instant lastModified)
private boolean validateIfNoneMatch(java.lang.String etag)
private java.lang.String padEtagIfNecessary(java.lang.String etag)
private boolean validateIfModifiedSince(java.time.Instant lastModified)