public final class MockServerRequest extends Object implements ServerRequest
ServerRequest.| Modifier and Type | Class and Description |
|---|---|
static interface |
MockServerRequest.Builder
Builder for
MockServerRequest. |
ServerRequest.Headers| Modifier and Type | Method and Description |
|---|---|
Map<String,Object> |
attributes()
Get a mutable map of request attributes.
|
<S> S |
body(BodyExtractor<S,? super ServerHttpRequest> extractor)
Extract the body with the given
BodyExtractor. |
<S> S |
body(BodyExtractor<S,? super ServerHttpRequest> extractor,
Map<String,Object> hints)
Extract the body with the given
BodyExtractor and hints. |
<S> reactor.core.publisher.Flux<S> |
bodyToFlux(Class<? extends S> elementClass)
Extract the body to a
Flux. |
<S> reactor.core.publisher.Flux<S> |
bodyToFlux(ParameterizedTypeReference<S> typeReference)
Extract the body to a
Flux. |
<S> reactor.core.publisher.Mono<S> |
bodyToMono(Class<? extends S> elementClass)
Extract the body to a
Mono. |
<S> reactor.core.publisher.Mono<S> |
bodyToMono(ParameterizedTypeReference<S> typeReference)
Extract the body to a
Mono. |
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. |
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.
|
RequestPath |
requestPath()
Get the request path as a
PathContainer. |
reactor.core.publisher.Mono<WebSession> |
session()
Get the web session for this request.
|
URI |
uri()
Get the request URI.
|
UriBuilder |
uriBuilder()
Get a
UriBuilderComponents from the URI associated with this
ServerRequest. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitattribute, checkNotModified, checkNotModified, checkNotModified, create, from, path, pathContainer, pathVariable, queryParampublic HttpMethod method()
ServerRequestmethod in interface ServerRequestnull
if not resolvable (e.g. in case of a non-standard HTTP method)public String methodName()
ServerRequestmethodName in interface ServerRequestpublic URI uri()
ServerRequesturi in interface ServerRequestpublic UriBuilder uriBuilder()
ServerRequestUriBuilderComponents from the URI associated with this
ServerRequest.
Note: as of 5.1 this method ignores "Forwarded"
and "X-Forwarded-*" headers that specify the
client-originated address. Consider using the ForwardedHeaderFilter
to extract and use, or to discard such headers.
uriBuilder in interface ServerRequestpublic RequestPath requestPath()
ServerRequestPathContainer.requestPath in interface ServerRequestpublic ServerRequest.Headers headers()
ServerRequestheaders in interface ServerRequestpublic MultiValueMap<String,HttpCookie> cookies()
ServerRequestcookies in interface ServerRequestpublic Optional<InetSocketAddress> remoteAddress()
ServerRequestremoteAddress in interface ServerRequestpublic Optional<InetSocketAddress> localAddress()
ServerRequestlocalAddress in interface ServerRequestpublic List<HttpMessageReader<?>> messageReaders()
ServerRequestmessageReaders in interface ServerRequestpublic <S> S body(BodyExtractor<S,? super ServerHttpRequest> extractor)
ServerRequestBodyExtractor.body in interface ServerRequestS - the type of the body returnedextractor - the BodyExtractor that reads from the requestServerRequest.body(BodyExtractor, Map)public <S> S body(BodyExtractor<S,? super ServerHttpRequest> extractor, Map<String,Object> hints)
ServerRequestBodyExtractor and hints.body in interface ServerRequestS - the type of the body returnedextractor - the BodyExtractor that reads from the requesthints - the map of hints like Jackson2CodecSupport.JSON_VIEW_HINT
to use to customize body extractionpublic <S> reactor.core.publisher.Mono<S> bodyToMono(Class<? extends S> elementClass)
ServerRequestMono.bodyToMono in interface ServerRequestS - the element typeelementClass - the class of element in the Monopublic <S> reactor.core.publisher.Mono<S> bodyToMono(ParameterizedTypeReference<S> typeReference)
ServerRequestMono.bodyToMono in interface ServerRequestS - the element typetypeReference - a type reference describing the expected response request typeTpublic <S> reactor.core.publisher.Flux<S> bodyToFlux(Class<? extends S> elementClass)
ServerRequestFlux.bodyToFlux in interface ServerRequestS - the element typeelementClass - the class of element in the Fluxpublic <S> reactor.core.publisher.Flux<S> bodyToFlux(ParameterizedTypeReference<S> typeReference)
ServerRequestFlux.bodyToFlux in interface ServerRequestS - the element typetypeReference - a type reference describing the expected request body typeTpublic Map<String,Object> attributes()
ServerRequestattributes in interface ServerRequestpublic MultiValueMap<String,String> queryParams()
ServerRequestqueryParams in interface ServerRequestpublic Map<String,String> pathVariables()
ServerRequestpathVariables in interface ServerRequestpublic reactor.core.publisher.Mono<WebSession> session()
ServerRequestAlways 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 in interface ServerRequestpublic reactor.core.publisher.Mono<? extends Principal> principal()
ServerRequestprincipal in interface ServerRequestpublic reactor.core.publisher.Mono<MultiValueMap<String,String>> formData()
ServerRequest"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 in interface ServerRequestpublic reactor.core.publisher.Mono<MultiValueMap<String,Part>> multipartData()
ServerRequest"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 in interface ServerRequestpublic ServerWebExchange exchange()
ServerRequestNote: Manipulating the exchange directly (instead of using the methods provided on
ServerRequest and ServerResponse) can lead to irregular results.
exchange in interface ServerRequestpublic static MockServerRequest.Builder builder()