Class MockServerRequest
- All Implemented Interfaces:
- ServerRequest
ServerRequest.- Since:
- 5.0
- Author:
- Arjen Poutsma
- 
Nested Class SummaryNested ClassesNested classes/interfaces inherited from interface org.springframework.web.reactive.function.server.ServerRequestServerRequest.Headers
- 
Method SummaryModifier and TypeMethodDescriptionGet a mutable map of request attributes.<T> reactor.core.publisher.Mono<T>Bind to this request and return an instance of the given type.<T> reactor.core.publisher.Mono<T>bind(Class<T> bindType, Consumer<WebDataBinder> dataBinderCustomizer) Bind to this request and return an instance of the given type.<S> Sbody(BodyExtractor<S, ? super ServerHttpRequest> extractor) Extract the body with the givenBodyExtractor.<S> Sbody(BodyExtractor<S, ? super ServerHttpRequest> extractor, Map<String, Object> hints) Extract the body with the givenBodyExtractorand 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.Builderbuilder()cookies()Get the cookies of this request.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.headers()Get the headers of this request.Get the local address to which this request is connected, if available.Get the readers used to convert the body of this request.method()Get the HTTP method.Deprecated.reactor.core.publisher.Mono<MultiValueMap<String,Part>> Get the parts of a multipart request if the Content-Type is"multipart/form-data"or an empty map otherwise.Get all path variables for this request.reactor.core.publisher.Mono<? extends Principal>Get the authenticated user for the request, if any.Get all query parameters for this request.Get the remote address to which this request is connected, if available.Get the request path as aPathContainer.reactor.core.publisher.Mono<WebSession>session()Get the web session for this request.uri()Get the request URI.Get aUriBuilderComponentsfrom the URI associated with thisServerRequest.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.web.reactive.function.server.ServerRequestattribute, checkNotModified, checkNotModified, checkNotModified, path, pathContainer, pathVariable, queryParam
- 
Method Details- 
methodDescription copied from interface:ServerRequestGet the HTTP method.- Specified by:
- methodin interface- ServerRequest
 
- 
methodNameDeprecated.Description copied from interface:ServerRequestGet the name of the HTTP method.- Specified by:
- methodNamein interface- ServerRequest
- Returns:
- the HTTP method as a String
 
- 
uriDescription copied from interface:ServerRequestGet the request URI.- Specified by:
- uriin interface- ServerRequest
 
- 
uriBuilderDescription copied from interface:ServerRequestGet aUriBuilderComponentsfrom 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 theForwardedHeaderFilterto extract and use, or to discard such headers.- Specified by:
- uriBuilderin interface- ServerRequest
- Returns:
- a URI builder
 
- 
requestPathDescription copied from interface:ServerRequestGet the request path as aPathContainer.- Specified by:
- requestPathin interface- ServerRequest
 
- 
headersDescription copied from interface:ServerRequestGet the headers of this request.- Specified by:
- headersin interface- ServerRequest
 
- 
cookiesDescription copied from interface:ServerRequestGet the cookies of this request.- Specified by:
- cookiesin interface- ServerRequest
 
- 
remoteAddressDescription copied from interface:ServerRequestGet the remote address to which this request is connected, if available.- Specified by:
- remoteAddressin interface- ServerRequest
 
- 
localAddressDescription copied from interface:ServerRequestGet the local address to which this request is connected, if available.- Specified by:
- localAddressin interface- ServerRequest
 
- 
messageReadersDescription copied from interface:ServerRequestGet the readers used to convert the body of this request.- Specified by:
- messageReadersin interface- ServerRequest
 
- 
bodyDescription copied from interface:ServerRequestExtract the body with the givenBodyExtractor.- Specified by:
- bodyin interface- ServerRequest
- Type Parameters:
- S- the type of the body returned
- Parameters:
- extractor- the- BodyExtractorthat reads from the request
- Returns:
- the extracted body
- See Also:
 
- 
bodyDescription copied from interface:ServerRequestExtract the body with the givenBodyExtractorand hints.- Specified by:
- bodyin interface- ServerRequest
- Type Parameters:
- S- the type of the body returned
- Parameters:
- extractor- the- BodyExtractorthat reads from the request
- hints- the map of hints like- Jackson2CodecSupport.JSON_VIEW_HINTto use to customize body extraction
- Returns:
- the extracted body
 
- 
bodyToMonoDescription copied from interface:ServerRequestExtract the body to aMono.- Specified by:
- bodyToMonoin interface- ServerRequest
- Type Parameters:
- S- the element type
- Parameters:
- elementClass- the class of element in the- Mono
- Returns:
- the body as a mono
 
- 
bodyToMonoDescription copied from interface:ServerRequestExtract the body to aMono.- Specified by:
- bodyToMonoin interface- ServerRequest
- Type Parameters:
- S- the element type
- Parameters:
- typeReference- a type reference describing the expected response request type
- Returns:
- a mono containing the body of the given type T
 
- 
bodyToFluxDescription copied from interface:ServerRequestExtract the body to aFlux.- Specified by:
- bodyToFluxin interface- ServerRequest
- Type Parameters:
- S- the element type
- Parameters:
- elementClass- the class of element in the- Flux
- Returns:
- the body as a flux
 
- 
bodyToFluxDescription copied from interface:ServerRequestExtract the body to aFlux.- Specified by:
- bodyToFluxin interface- ServerRequest
- Type Parameters:
- S- the element type
- Parameters:
- typeReference- a type reference describing the expected request body type
- Returns:
- a flux containing the body of the given type T
 
- 
bindDescription copied from interface:ServerRequestBind to this request and return an instance of the given type.- Specified by:
- bindin interface- ServerRequest
- Type Parameters:
- T- the type to bind to
- Parameters:
- bindType- the type of class to bind this request to
- Returns:
- a mono containing either a constructed and bound instance of
 bindType, or aBindExceptionin case of binding errors
 
- 
bindpublic <T> reactor.core.publisher.Mono<T> bind(Class<T> bindType, Consumer<WebDataBinder> dataBinderCustomizer) Description copied from interface:ServerRequestBind to this request and return an instance of the given type.- Specified by:
- bindin interface- ServerRequest
- Type Parameters:
- T- the type to bind to
- Parameters:
- bindType- the type of class to bind this request to
- dataBinderCustomizer- used to customize the data binder, for example, set (dis)allowed fields
- Returns:
- a mono containing either a constructed and bound instance of
 bindType, or aBindExceptionin case of binding errors
 
- 
attributesDescription copied from interface:ServerRequestGet a mutable map of request attributes.- Specified by:
- attributesin interface- ServerRequest
- Returns:
- the request attributes
 
- 
queryParamsDescription copied from interface:ServerRequestGet all query parameters for this request.- Specified by:
- queryParamsin interface- ServerRequest
 
- 
pathVariablesDescription copied from interface:ServerRequestGet all path variables for this request.- Specified by:
- pathVariablesin interface- ServerRequest
 
- 
sessionDescription copied from interface:ServerRequestGet 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. - Specified by:
- sessionin interface- ServerRequest
 
- 
principalDescription copied from interface:ServerRequestGet the authenticated user for the request, if any.- Specified by:
- principalin interface- ServerRequest
 
- 
formDataDescription copied from interface:ServerRequestGet 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 MultiValueMapis cached so that this method is safe to call more than once.- Specified by:
- formDatain interface- ServerRequest
 
- 
multipartDataDescription copied from interface:ServerRequestGet 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 MultiValueMapis cached so that this method is safe to call more than once.- Specified by:
- multipartDatain interface- ServerRequest
 
- 
exchangeDescription copied from interface:ServerRequestGet the web exchange that this request is based on.Note: Manipulating the exchange directly (instead of using the methods provided on ServerRequestandServerResponse) can lead to irregular results.- Specified by:
- exchangein interface- ServerRequest
 
- 
builder
 
-