类 DefaultServerWebExchange
- java.lang.Object
- org.springframework.web.server.adapter.DefaultServerWebExchange
- 所有已实现的接口:
ServerWebExchange
- 直接已知子类:
MockServerWebExchange
public class DefaultServerWebExchange extends Object implements ServerWebExchange
Default implementation ofServerWebExchange
.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev
嵌套类概要
从接口继承的嵌套类/接口 org.springframework.web.server.ServerWebExchange
ServerWebExchange.Builder
字段概要
从接口继承的字段 org.springframework.web.server.ServerWebExchange
LOG_ID_ATTRIBUTE
构造器概要
构造器 构造器 说明 DefaultServerWebExchange(ServerHttpRequest request, ServerHttpResponse response, WebSessionManager sessionManager, ServerCodecConfigurer codecConfigurer, LocaleContextResolver localeContextResolver)
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
addUrlTransformer(Function<String,String> transformer)
Register an additional URL transformation function for use withServerWebExchange.transformUrl(java.lang.String)
.boolean
checkNotModified(String etag)
An overloaded variant ofServerWebExchange.checkNotModified(String, Instant)
with anETag
(entity tag) value only.boolean
checkNotModified(String etag, Instant lastModified)
Check whether the requested resource has been modified given the suppliedETag
(entity tag) and last-modified timestamp as determined by the application.boolean
checkNotModified(Instant lastModified)
An overloaded variant ofServerWebExchange.checkNotModified(String, Instant)
with a last-modified timestamp only.ApplicationContext
getApplicationContext()
Return theApplicationContext
associated with the web application, if it was initialized with one viaWebHttpHandlerBuilder.applicationContext(ApplicationContext)
.Map<String,Object>
getAttributes()
Return a mutable map of request attributes for the current exchange.reactor.core.publisher.Mono<MultiValueMap<String,String>>
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 otherwise.LocaleContext
getLocaleContext()
Return theLocaleContext
using the configuredLocaleContextResolver
.String
getLogPrefix()
Return a log message prefix to use to correlate messages for this exchange.reactor.core.publisher.Mono<MultiValueMap<String,Part>>
getMultipartData()
Return the parts of a multipart request if the Content-Type is"multipart/form-data"
or an empty map otherwise.<T extends Principal>
reactor.core.publisher.Mono<T>getPrincipal()
Return the authenticated user for the request, if any.ServerHttpRequest
getRequest()
Return the current HTTP request.ServerHttpResponse
getResponse()
Return the current HTTP response.reactor.core.publisher.Mono<WebSession>
getSession()
Return the web session for the current request.boolean
isNotModified()
Returnstrue
if the one of thecheckNotModified
methods in this contract were used and they returned true.String
transformUrl(String url)
Transform the given url according to the registered transformation function(s).从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 org.springframework.web.server.ServerWebExchange
getAttribute, getAttributeOrDefault, getRequiredAttribute, mutate
构造器详细资料
DefaultServerWebExchange
public DefaultServerWebExchange(ServerHttpRequest request, ServerHttpResponse response, WebSessionManager sessionManager, ServerCodecConfigurer codecConfigurer, LocaleContextResolver localeContextResolver)
方法详细资料
getRequest
public ServerHttpRequest getRequest()
从接口复制的说明:ServerWebExchange
Return the current HTTP request.- 指定者:
getRequest
在接口中ServerWebExchange
getResponse
public ServerHttpResponse getResponse()
从接口复制的说明:ServerWebExchange
Return the current HTTP response.- 指定者:
getResponse
在接口中ServerWebExchange
getAttributes
public Map<String,Object> getAttributes()
从接口复制的说明:ServerWebExchange
Return a mutable map of request attributes for the current exchange.- 指定者:
getAttributes
在接口中ServerWebExchange
getSession
public reactor.core.publisher.Mono<WebSession> getSession()
从接口复制的说明:ServerWebExchange
Return the web session for the current request. Always guaranteed to return an instance either matching to the session id requested by the client, or with a new session id either because the client did not specify one or because the underlying session had expired. Use of this method does not automatically create a session. SeeWebSession
for more details.- 指定者:
getSession
在接口中ServerWebExchange
getPrincipal
public <T extends Principal> reactor.core.publisher.Mono<T> getPrincipal()
从接口复制的说明:ServerWebExchange
Return the authenticated user for the request, if any.- 指定者:
getPrincipal
在接口中ServerWebExchange
getFormData
public reactor.core.publisher.Mono<MultiValueMap<String,String>> getFormData()
从接口复制的说明:ServerWebExchange
Return the form data from the body of the request if the Content-Type is"application/x-www-form-urlencoded"
or an empty map otherwise.Note: calling this method causes the request body to be read and parsed in full and the resulting
MultiValueMap
is cached so that this method is safe to call more than once.- 指定者:
getFormData
在接口中ServerWebExchange
getMultipartData
public reactor.core.publisher.Mono<MultiValueMap<String,Part>> getMultipartData()
从接口复制的说明:ServerWebExchange
Return the parts of a multipart request if the Content-Type is"multipart/form-data"
or an empty map otherwise.Note: calling this method causes the request body to be read and parsed in full and the resulting
MultiValueMap
is cached so that this method is safe to call more than once.Note:the contents of each part is not cached, and can only be read once.
- 指定者:
getMultipartData
在接口中ServerWebExchange
getLocaleContext
public LocaleContext getLocaleContext()
从接口复制的说明:ServerWebExchange
Return theLocaleContext
using the configuredLocaleContextResolver
.- 指定者:
getLocaleContext
在接口中ServerWebExchange
getApplicationContext
@Nullable public ApplicationContext getApplicationContext()
从接口复制的说明:ServerWebExchange
Return theApplicationContext
associated with the web application, if it was initialized with one viaWebHttpHandlerBuilder.applicationContext(ApplicationContext)
.
isNotModified
public boolean isNotModified()
从接口复制的说明:ServerWebExchange
Returnstrue
if the one of thecheckNotModified
methods in this contract were used and they returned true.- 指定者:
isNotModified
在接口中ServerWebExchange
checkNotModified
public boolean checkNotModified(Instant lastModified)
从接口复制的说明:ServerWebExchange
An overloaded variant ofServerWebExchange.checkNotModified(String, Instant)
with a last-modified timestamp only.- 指定者:
checkNotModified
在接口中ServerWebExchange
- 参数:
lastModified
- the last-modified time- 返回:
- whether the request qualifies as not modified
checkNotModified
public boolean checkNotModified(String etag)
从接口复制的说明:ServerWebExchange
An overloaded variant ofServerWebExchange.checkNotModified(String, Instant)
with anETag
(entity tag) value only.- 指定者:
checkNotModified
在接口中ServerWebExchange
- 参数:
etag
- the entity tag for the underlying resource.- 返回:
- true if the request does not require further processing.
checkNotModified
public boolean checkNotModified(@Nullable String etag, Instant lastModified)
从接口复制的说明:ServerWebExchange
Check whether the requested resource has been modified given the suppliedETag
(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)
orServerWebExchange.checkNotModified(Instant)
.- 指定者:
checkNotModified
在接口中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 resource- 返回:
- true if the request does not require further processing.
transformUrl
public String transformUrl(String url)
从接口复制的说明:ServerWebExchange
Transform the given url according to the registered transformation function(s). By default, this method returns the givenurl
, though additional transformation functions can by registered withServerWebExchange.addUrlTransformer(java.util.function.Function<java.lang.String, java.lang.String>)
- 指定者:
transformUrl
在接口中ServerWebExchange
- 参数:
url
- the URL to transform- 返回:
- the transformed URL
addUrlTransformer
public void addUrlTransformer(Function<String,String> transformer)
从接口复制的说明:ServerWebExchange
Register an additional URL transformation function for use withServerWebExchange.transformUrl(java.lang.String)
. The given function can be used to insert an id for authentication, a nonce for CSRF protection, etc.Note that the given function is applied after any previously registered functions.
- 指定者:
addUrlTransformer
在接口中ServerWebExchange
- 参数:
transformer
- a URL transformation function to add
getLogPrefix
public String getLogPrefix()
从接口复制的说明:ServerWebExchange
Return a log message prefix to use to correlate messages for this exchange. The prefix is based on the value of the attributeServerWebExchange.LOG_ID_ATTRIBUTE
along with some extra formatting so that the prefix can be conveniently prepended with no further formatting no separators required.- 指定者:
getLogPrefix
在接口中ServerWebExchange
- 返回:
- the log message prefix or an empty String if the
ServerWebExchange.LOG_ID_ATTRIBUTE
is not set.