类 MockServerRequest
- java.lang.Object
- org.springframework.mock.web.reactive.function.server.MockServerRequest
- 所有已实现的接口:
ServerRequest
public final class MockServerRequest extends Object implements ServerRequest
Mock implementation ofServerRequest
.- 从以下版本开始:
- 5.0
- 作者:
- Arjen Poutsma
嵌套类概要
嵌套类 修饰符和类型 类 说明 static interface
MockServerRequest.Builder
Builder forMockServerRequest
.从接口继承的嵌套类/接口 org.springframework.web.reactive.function.server.ServerRequest
ServerRequest.Headers
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 Map<String,Object>
attributes()
Get a mutable map of request attributes.<S> S
body(BodyExtractor<S,? super ServerHttpRequest> extractor)
Extract the body with the givenBodyExtractor
.<S> S
body(BodyExtractor<S,? super ServerHttpRequest> extractor, Map<String,Object> hints)
Extract the body with the givenBodyExtractor
and hints.<S> reactor.core.publisher.Flux<S>
bodyToFlux(Class<? extends S> elementClass)
Extract the body to aFlux
.<S> reactor.core.publisher.Flux<S>
bodyToFlux(ParameterizedTypeReference<S> typeReference)
Extract the body to aFlux
.<S> reactor.core.publisher.Mono<S>
bodyToMono(Class<? extends S> elementClass)
Extract the body to aMono
.<S> reactor.core.publisher.Mono<S>
bodyToMono(ParameterizedTypeReference<S> typeReference)
Extract the body to aMono
.static MockServerRequest.Builder
builder()
MultiValueMap<String,HttpCookie>
cookies()
Get the cookies of this request.ServerWebExchange
exchange()
Get the web exchange that this request is based on.reactor.core.publisher.Mono<MultiValueMap<String,String>>
formData()
Get the form data from the body of the request if the Content-Type is"application/x-www-form-urlencoded"
or an empty map otherwise.ServerRequest.Headers
headers()
Get the headers of this request.Optional<InetSocketAddress>
localAddress()
Get the local address to which this request is connected, if available.List<HttpMessageReader<?>>
messageReaders()
Get the readers used to convert the body of this request.HttpMethod
method()
Get the HTTP method.String
methodName()
Get the name of the HTTP method.reactor.core.publisher.Mono<MultiValueMap<String,Part>>
multipartData()
Get the parts of a multipart request if the Content-Type is"multipart/form-data"
or an empty map otherwise.PathContainer
pathContainer()
Get the request path as aPathContainer
.Map<String,String>
pathVariables()
Get all path variables for this request.reactor.core.publisher.Mono<? extends Principal>
principal()
Get the authenticated user for the request, if any.MultiValueMap<String,String>
queryParams()
Get all query parameters for this request.Optional<InetSocketAddress>
remoteAddress()
Get the remote address to which this request is connected, if available.reactor.core.publisher.Mono<WebSession>
session()
Get the web session for this request.URI
uri()
Get the request URI.UriBuilder
uriBuilder()
Get aUriBuilderComponents
from the URI associated with thisServerRequest
.从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 org.springframework.web.reactive.function.server.ServerRequest
attribute, checkNotModified, checkNotModified, checkNotModified, path, pathVariable, queryParam
方法详细资料
method
public HttpMethod method()
从接口复制的说明:ServerRequest
Get the HTTP method.- 指定者:
method
在接口中ServerRequest
- 返回:
- the HTTP method as an HttpMethod enum value, or
null
if not resolvable (e.g. in case of a non-standard HTTP method)
methodName
public String methodName()
从接口复制的说明:ServerRequest
Get the name of the HTTP method.- 指定者:
methodName
在接口中ServerRequest
- 返回:
- the HTTP method as a String
uri
public URI uri()
从接口复制的说明:ServerRequest
Get the request URI.- 指定者:
uri
在接口中ServerRequest
uriBuilder
public UriBuilder uriBuilder()
从接口复制的说明:ServerRequest
Get aUriBuilderComponents
from the URI associated with thisServerRequest
.Note: as of 5.1 this method ignores
"Forwarded"
and"X-Forwarded-*"
headers that specify the client-originated address. Consider using theForwardedHeaderFilter
to extract and use, or to discard such headers.- 指定者:
uriBuilder
在接口中ServerRequest
- 返回:
- a URI builder
pathContainer
public PathContainer pathContainer()
从接口复制的说明:ServerRequest
Get the request path as aPathContainer
.- 指定者:
pathContainer
在接口中ServerRequest
headers
public ServerRequest.Headers headers()
从接口复制的说明:ServerRequest
Get the headers of this request.- 指定者:
headers
在接口中ServerRequest
cookies
public MultiValueMap<String,HttpCookie> cookies()
从接口复制的说明:ServerRequest
Get the cookies of this request.- 指定者:
cookies
在接口中ServerRequest
remoteAddress
public Optional<InetSocketAddress> remoteAddress()
从接口复制的说明:ServerRequest
Get the remote address to which this request is connected, if available.- 指定者:
remoteAddress
在接口中ServerRequest
localAddress
public Optional<InetSocketAddress> localAddress()
从接口复制的说明:ServerRequest
Get the local address to which this request is connected, if available.- 指定者:
localAddress
在接口中ServerRequest
messageReaders
public List<HttpMessageReader<?>> messageReaders()
从接口复制的说明:ServerRequest
Get the readers used to convert the body of this request.- 指定者:
messageReaders
在接口中ServerRequest
body
public <S> S body(BodyExtractor<S,? super ServerHttpRequest> extractor)
从接口复制的说明:ServerRequest
Extract the body with the givenBodyExtractor
.- 指定者:
body
在接口中ServerRequest
- 类型参数:
S
- the type of the body returned- 参数:
extractor
- theBodyExtractor
that reads from the request- 返回:
- the extracted body
- 另请参阅:
ServerRequest.body(BodyExtractor, Map)
body
public <S> S body(BodyExtractor<S,? super ServerHttpRequest> extractor, Map<String,Object> hints)
从接口复制的说明:ServerRequest
Extract the body with the givenBodyExtractor
and hints.- 指定者:
body
在接口中ServerRequest
- 类型参数:
S
- the type of the body returned- 参数:
extractor
- theBodyExtractor
that reads from the requesthints
- the map of hints likeJackson2CodecSupport.JSON_VIEW_HINT
to use to customize body extraction- 返回:
- the extracted body
bodyToMono
public <S> reactor.core.publisher.Mono<S> bodyToMono(Class<? extends S> elementClass)
从接口复制的说明:ServerRequest
Extract the body to aMono
.- 指定者:
bodyToMono
在接口中ServerRequest
- 类型参数:
S
- the element type- 参数:
elementClass
- the class of element in theMono
- 返回:
- the body as a mono
bodyToMono
public <S> reactor.core.publisher.Mono<S> bodyToMono(ParameterizedTypeReference<S> typeReference)
从接口复制的说明:ServerRequest
Extract the body to aMono
.- 指定者:
bodyToMono
在接口中ServerRequest
- 类型参数:
S
- the element type- 参数:
typeReference
- a type reference describing the expected response request type- 返回:
- a mono containing the body of the given type
T
bodyToFlux
public <S> reactor.core.publisher.Flux<S> bodyToFlux(Class<? extends S> elementClass)
从接口复制的说明:ServerRequest
Extract the body to aFlux
.- 指定者:
bodyToFlux
在接口中ServerRequest
- 类型参数:
S
- the element type- 参数:
elementClass
- the class of element in theFlux
- 返回:
- the body as a flux
bodyToFlux
public <S> reactor.core.publisher.Flux<S> bodyToFlux(ParameterizedTypeReference<S> typeReference)
从接口复制的说明:ServerRequest
Extract the body to aFlux
.- 指定者:
bodyToFlux
在接口中ServerRequest
- 类型参数:
S
- the element type- 参数:
typeReference
- a type reference describing the expected request body type- 返回:
- a flux containing the body of the given type
T
attributes
public Map<String,Object> attributes()
从接口复制的说明:ServerRequest
Get a mutable map of request attributes.- 指定者:
attributes
在接口中ServerRequest
- 返回:
- the request attributes
queryParams
public MultiValueMap<String,String> queryParams()
从接口复制的说明:ServerRequest
Get all query parameters for this request.- 指定者:
queryParams
在接口中ServerRequest
pathVariables
public Map<String,String> pathVariables()
从接口复制的说明:ServerRequest
Get all path variables for this request.- 指定者:
pathVariables
在接口中ServerRequest
session
public reactor.core.publisher.Mono<WebSession> session()
从接口复制的说明:ServerRequest
Get the web session for this request.Always guaranteed to return an instance either matching 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.
- 指定者:
session
在接口中ServerRequest
principal
public reactor.core.publisher.Mono<? extends Principal> principal()
从接口复制的说明:ServerRequest
Get the authenticated user for the request, if any.- 指定者:
principal
在接口中ServerRequest
formData
public reactor.core.publisher.Mono<MultiValueMap<String,String>> formData()
从接口复制的说明:ServerRequest
Get 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.- 指定者:
formData
在接口中ServerRequest
multipartData
public reactor.core.publisher.Mono<MultiValueMap<String,Part>> multipartData()
从接口复制的说明:ServerRequest
Get 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.- 指定者:
multipartData
在接口中ServerRequest
exchange
public ServerWebExchange exchange()
从接口复制的说明:ServerRequest
Get the web exchange that this request is based on.Note: Manipulating the exchange directly (instead of using the methods provided on
ServerRequest
andServerResponse
) can lead to irregular results.- 指定者:
exchange
在接口中ServerRequest
builder
public static MockServerRequest.Builder builder()