Top Description Inners Fields Constructors Methods
org.springframework.web.reactive.function.server.support

public Class ServerRequestWrapper

extends Object
implements ServerRequest
Class Inheritance
All Implemented Interfaces
org.springframework.web.reactive.function.server.ServerRequest
Imports
java.net.InetSocketAddress, .URI, java.nio.charset.Charset, java.security.Principal, java.util.List, .Locale, .Map, .Optional, .OptionalLong, java.util.function.Consumer, reactor.core.publisher.Flux, .Mono, org.springframework.core.ParameterizedTypeReference, org.springframework.http.HttpCookie, .HttpHeaders, .HttpMethod, .HttpRange, .MediaType, org.springframework.http.codec.HttpMessageReader, org.springframework.http.codec.multipart.Part, org.springframework.http.server.PathContainer, .RequestPath, org.springframework.http.server.reactive.ServerHttpRequest, org.springframework.util.Assert, .MultiValueMap, org.springframework.web.bind.WebDataBinder, org.springframework.web.reactive.function.BodyExtractor, org.springframework.web.reactive.function.server.ServerRequest, org.springframework.web.server.ServerWebExchange, .WebSession, org.springframework.web.util.UriBuilder

Implementation of the ServerRequest interface that can be subclassed to adapt the request in a handler filter function. All methods default to calling through to the wrapped request.
Author
Arjen Poutsma
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ServerRequestWrapper.HeadersWrapper

Implementation of the Headers interface that can be subclassed to adapt the headers in a handler filter function.

Field Summary

Modifier and TypeField and Description
private final ServerRequest

Constructor Summary

AccessConstructor and Description
public
ServerRequestWrapper(ServerRequest
the request to wrap
delegate
)

Create a new ServerRequestWrapper that wraps the given request.

Method Summary

Modifier and TypeMethod and Description
public Optional<Object>
attribute(String
the attribute name
name
)

Overrides default org.springframework.web.reactive.function.server.ServerRequest.attribute.

Get the request attribute value if present.

public Map<String, Object>
attributes()

Implements org.springframework.web.reactive.function.server.ServerRequest.attributes.

Get a mutable map of request attributes.

public <T> Mono<T>
bind(Class<T>
the type of class to bind this request to
bindType
)

Overrides default org.springframework.web.reactive.function.server.ServerRequest.bind.

Bind to this request and return an instance of the given type.

public <T> Mono<T>
bind(Class<T>
the type of class to bind this request to
bindType
,
Consumer<WebDataBinder>
used to customize the data binder, e.g. set (dis)allowed fields
dataBinderCustomizer
)

Implements org.springframework.web.reactive.function.server.ServerRequest.bind.

Bind to this request and return an instance of the given type.

public <T> T
body(BodyExtractor<T, ? super ServerHttpRequest>
the BodyExtractor that reads from the request
extractor
)

Implements org.springframework.web.reactive.function.server.ServerRequest.body.

Extract the body with the given BodyExtractor.

public <T> T
body(BodyExtractor<T, ? super ServerHttpRequest>
the BodyExtractor that reads from the request
extractor
,
Map<String, Object>
the map of hints like Jackson2CodecSupport#JSON_VIEW_HINT to use to customize body extraction
hints
)

Implements org.springframework.web.reactive.function.server.ServerRequest.body.

Extract the body with the given BodyExtractor and hints.

public <T> Flux<T>
bodyToFlux(Class<? extends T>
the class of element in the Flux
elementClass
)

Implements org.springframework.web.reactive.function.server.ServerRequest.bodyToFlux.

Extract the body to a Flux.

public <T> Flux<T>
bodyToFlux(ParameterizedTypeReference<T>
a type reference describing the expected request body type
typeReference
)

Implements org.springframework.web.reactive.function.server.ServerRequest.bodyToFlux.

Extract the body to a Flux.

public <T> Mono<T>
bodyToMono(Class<? extends T>
the class of element in the Mono
elementClass
)

Implements org.springframework.web.reactive.function.server.ServerRequest.bodyToMono.

Extract the body to a Mono.

public <T> Mono<T>
bodyToMono(ParameterizedTypeReference<T>
a type reference describing the expected response request type
typeReference
)

Implements org.springframework.web.reactive.function.server.ServerRequest.bodyToMono.

Extract the body to a Mono.

public MultiValueMap<String, HttpCookie>
public ServerWebExchange
exchange()

Implements org.springframework.web.reactive.function.server.ServerRequest.exchange.

Get the web exchange that this request is based on.

public Mono<MultiValueMap<String, String>>
formData()

Implements org.springframework.web.reactive.function.server.ServerRequest.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.

public ServerRequest.Headers
public Optional<InetSocketAddress>
localAddress()

Implements org.springframework.web.reactive.function.server.ServerRequest.localAddress.

Get the local address to which this request is connected, if available.

public List<HttpMessageReader<?>>
messageReaders()

Implements org.springframework.web.reactive.function.server.ServerRequest.messageReaders.

Get the readers used to convert the body of this request.

public HttpMethod
public String
methodName()

Implements org.springframework.web.reactive.function.server.ServerRequest.methodName.

Deprecated

Get the name of the HTTP method.

public Mono<MultiValueMap<String, Part>>
multipartData()

Implements org.springframework.web.reactive.function.server.ServerRequest.multipartData.

Get the parts of a multipart request if the Content-Type is "multipart/form-data" or an empty map otherwise.

public String
public PathContainer
pathContainer()

Overrides default org.springframework.web.reactive.function.server.ServerRequest.pathContainer.

Deprecated

Get the request path as a PathContainer.

public String
pathVariable(String
the variable name
name
)

Overrides default org.springframework.web.reactive.function.server.ServerRequest.pathVariable.

Get the path variable with the given name, if present.

public Map<String, String>
public Mono<? extends Principal>
principal()

Implements org.springframework.web.reactive.function.server.ServerRequest.principal.

Get the authenticated user for the request, if any.

public Optional<String>
queryParam(String
the parameter name
name
)

Overrides default org.springframework.web.reactive.function.server.ServerRequest.queryParam.

Get the first query parameter with the given name, if present.

public MultiValueMap<String, String>
queryParams()

Implements org.springframework.web.reactive.function.server.ServerRequest.queryParams.

Get all query parameters for this request.

public Optional<InetSocketAddress>
remoteAddress()

Implements org.springframework.web.reactive.function.server.ServerRequest.remoteAddress.

Get the remote address to which this request is connected, if available.

public ServerRequest
request()

Return the wrapped request.

public RequestPath
requestPath()

Overrides default org.springframework.web.reactive.function.server.ServerRequest.requestPath.

Get the request path as a PathContainer.

public Mono<WebSession>
session()

Implements org.springframework.web.reactive.function.server.ServerRequest.session.

Get the web session for this request.

public URI
public UriBuilder
uriBuilder()

Implements org.springframework.web.reactive.function.server.ServerRequest.uriBuilder.

Get a UriBuilderComponents from the URI associated with this ServerRequest.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateback to summary
private final ServerRequest delegate

Constructor Detail

ServerRequestWrapperback to summary
public ServerRequestWrapper(ServerRequest delegate)

Create a new ServerRequestWrapper that wraps the given request.

Parameters
delegate:ServerRequest

the request to wrap

Method Detail

attributeback to summary
public Optional<Object> attribute(String name)

Overrides default org.springframework.web.reactive.function.server.ServerRequest.attribute.

Doc from org.springframework.web.reactive.function.server.ServerRequest.attribute.

Get the request attribute value if present.

Parameters
name:String

the attribute name

Returns:Optional<Object>

the attribute value

Annotations
@Override
attributesback to summary
public Map<String, Object> attributes()

Implements org.springframework.web.reactive.function.server.ServerRequest.attributes.

Doc from org.springframework.web.reactive.function.server.ServerRequest.attributes.

Get a mutable map of request attributes.

Returns:Map<String, Object>

the request attributes

Annotations
@Override
bindback to summary
public <T> Mono<T> bind(Class<T> bindType)

Overrides default org.springframework.web.reactive.function.server.ServerRequest.bind.

Doc from org.springframework.web.reactive.function.server.ServerRequest.bind.

Bind to this request and return an instance of the given type.

Parameters
<T>
the type to bind to
bindType:Class<T>

the type of class to bind this request to

Returns:Mono<T>

a mono containing either a constructed and bound instance of bindType, or a BindException in case of binding errors

Annotations
@Override
bindback to summary
public <T> Mono<T> bind(Class<T> bindType, Consumer<WebDataBinder> dataBinderCustomizer)

Implements org.springframework.web.reactive.function.server.ServerRequest.bind.

Doc from org.springframework.web.reactive.function.server.ServerRequest.bind.

Bind to this request and return an instance of the given type.

Parameters
<T>
the type to bind to
bindType:Class<T>

the type of class to bind this request to

dataBinderCustomizer:Consumer<WebDataBinder>

used to customize the data binder, e.g. set (dis)allowed fields

Returns:Mono<T>

a mono containing either a constructed and bound instance of bindType, or a BindException in case of binding errors

Annotations
@Override
bodyback to summary
public <T> T body(BodyExtractor<T, ? super ServerHttpRequest> extractor)

Implements org.springframework.web.reactive.function.server.ServerRequest.body.

Doc from org.springframework.web.reactive.function.server.ServerRequest.body.

Extract the body with the given BodyExtractor.

Parameters
<T>
the type of the body returned
extractor:BodyExtractor<T, ? super ServerHttpRequest>

the BodyExtractor that reads from the request

Returns:T

the extracted body

Annotations
@Override
bodyback to summary
public <T> T body(BodyExtractor<T, ? super ServerHttpRequest> extractor, Map<String, Object> hints)

Implements org.springframework.web.reactive.function.server.ServerRequest.body.

Doc from org.springframework.web.reactive.function.server.ServerRequest.body.

Extract the body with the given BodyExtractor and hints.

Parameters
<T>
the type of the body returned
extractor:BodyExtractor<T, ? super ServerHttpRequest>

the BodyExtractor that reads from the request

hints:Map<String, Object>

the map of hints like Jackson2CodecSupport#JSON_VIEW_HINT to use to customize body extraction

Returns:T

the extracted body

Annotations
@Override
bodyToFluxback to summary
public <T> Flux<T> bodyToFlux(Class<? extends T> elementClass)

Implements org.springframework.web.reactive.function.server.ServerRequest.bodyToFlux.

Doc from org.springframework.web.reactive.function.server.ServerRequest.bodyToFlux.

Extract the body to a Flux.

Parameters
<T>
the element type
elementClass:Class<? extends T>

the class of element in the Flux

Returns:Flux<T>

the body as a flux

Annotations
@Override
bodyToFluxback to summary
public <T> Flux<T> bodyToFlux(ParameterizedTypeReference<T> typeReference)

Implements org.springframework.web.reactive.function.server.ServerRequest.bodyToFlux.

Doc from org.springframework.web.reactive.function.server.ServerRequest.bodyToFlux.

Extract the body to a Flux.

Parameters
<T>
the element type
typeReference:ParameterizedTypeReference<T>

a type reference describing the expected request body type

Returns:Flux<T>

a flux containing the body of the given type T

Annotations
@Override
bodyToMonoback to summary
public <T> Mono<T> bodyToMono(Class<? extends T> elementClass)

Implements org.springframework.web.reactive.function.server.ServerRequest.bodyToMono.

Doc from org.springframework.web.reactive.function.server.ServerRequest.bodyToMono.

Extract the body to a Mono.

Parameters
<T>
the element type
elementClass:Class<? extends T>

the class of element in the Mono

Returns:Mono<T>

the body as a mono

Annotations
@Override
bodyToMonoback to summary
public <T> Mono<T> bodyToMono(ParameterizedTypeReference<T> typeReference)

Implements org.springframework.web.reactive.function.server.ServerRequest.bodyToMono.

Doc from org.springframework.web.reactive.function.server.ServerRequest.bodyToMono.

Extract the body to a Mono.

Parameters
<T>
the element type
typeReference:ParameterizedTypeReference<T>

a type reference describing the expected response request type

Returns:Mono<T>

a mono containing the body of the given type T

Annotations
@Override
cookiesback to summary
public MultiValueMap<String, HttpCookie> cookies()

Implements org.springframework.web.reactive.function.server.ServerRequest.cookies.

Doc from org.springframework.web.reactive.function.server.ServerRequest.cookies.

Get the cookies of this request.

Annotations
@Override
exchangeback to summary
public ServerWebExchange exchange()

Implements org.springframework.web.reactive.function.server.ServerRequest.exchange.

Doc from org.springframework.web.reactive.function.server.ServerRequest.exchange.

Get the web exchange that this request is based on.

Note

Manipulating the exchange directly (instead of using the methods provided on ServerRequest and ServerResponse) can lead to irregular results.

Annotations
@Override
formDataback to summary
public Mono<MultiValueMap<String, String>> formData()

Implements org.springframework.web.reactive.function.server.ServerRequest.formData.

Doc from org.springframework.web.reactive.function.server.ServerRequest.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.

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.

Annotations
@Override
headersback to summary
public ServerRequest.Headers headers()

Implements org.springframework.web.reactive.function.server.ServerRequest.headers.

Doc from org.springframework.web.reactive.function.server.ServerRequest.headers.

Get the headers of this request.

Annotations
@Override
localAddressback to summary
public Optional<InetSocketAddress> localAddress()

Implements org.springframework.web.reactive.function.server.ServerRequest.localAddress.

Doc from org.springframework.web.reactive.function.server.ServerRequest.localAddress.

Get the local address to which this request is connected, if available.

Annotations
@Override
messageReadersback to summary
public List<HttpMessageReader<?>> messageReaders()

Implements org.springframework.web.reactive.function.server.ServerRequest.messageReaders.

Doc from org.springframework.web.reactive.function.server.ServerRequest.messageReaders.

Get the readers used to convert the body of this request.

Annotations
@Override
methodback to summary
public HttpMethod method()

Implements org.springframework.web.reactive.function.server.ServerRequest.method.

Doc from org.springframework.web.reactive.function.server.ServerRequest.method.

Get the HTTP method.

Annotations
@Override
methodNameback to summary
public String methodName()

Implements org.springframework.web.reactive.function.server.ServerRequest.methodName.

Doc from org.springframework.web.reactive.function.server.ServerRequest.methodName.

Deprecated

Get the name of the HTTP method.

Returns:String

the HTTP method as a String

Annotations
@Override
@Deprecated
multipartDataback to summary
public Mono<MultiValueMap<String, Part>> multipartData()

Implements org.springframework.web.reactive.function.server.ServerRequest.multipartData.

Doc from org.springframework.web.reactive.function.server.ServerRequest.multipartData.

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.

Annotations
@Override
pathback to summary
public String path()

Overrides default org.springframework.web.reactive.function.server.ServerRequest.path.

Doc from org.springframework.web.reactive.function.server.ServerRequest.path.

Get the request path.

Annotations
@Override
pathContainerback to summary
public PathContainer pathContainer()

Overrides default org.springframework.web.reactive.function.server.ServerRequest.pathContainer.

Doc from org.springframework.web.reactive.function.server.ServerRequest.pathContainer.

Deprecated

Get the request path as a PathContainer.

Annotations
@Override
@Deprecated
pathVariableback to summary
public String pathVariable(String name)

Overrides default org.springframework.web.reactive.function.server.ServerRequest.pathVariable.

Doc from org.springframework.web.reactive.function.server.ServerRequest.pathVariable.

Get the path variable with the given name, if present.

Parameters
name:String

the variable name

Returns:String

the variable value

Annotations
@Override
pathVariablesback to summary
public Map<String, String> pathVariables()

Implements org.springframework.web.reactive.function.server.ServerRequest.pathVariables.

Doc from org.springframework.web.reactive.function.server.ServerRequest.pathVariables.

Get all path variables for this request.

Annotations
@Override
principalback to summary
public Mono<? extends Principal> principal()

Implements org.springframework.web.reactive.function.server.ServerRequest.principal.

Doc from org.springframework.web.reactive.function.server.ServerRequest.principal.

Get the authenticated user for the request, if any.

Annotations
@Override
queryParamback to summary
public Optional<String> queryParam(String name)

Overrides default org.springframework.web.reactive.function.server.ServerRequest.queryParam.

Doc from org.springframework.web.reactive.function.server.ServerRequest.queryParam.

Get the first query parameter with the given name, if present.

Parameters
name:String

the parameter name

Returns:Optional<String>

the parameter value

Annotations
@Override
queryParamsback to summary
public MultiValueMap<String, String> queryParams()

Implements org.springframework.web.reactive.function.server.ServerRequest.queryParams.

Doc from org.springframework.web.reactive.function.server.ServerRequest.queryParams.

Get all query parameters for this request.

Annotations
@Override
remoteAddressback to summary
public Optional<InetSocketAddress> remoteAddress()

Implements org.springframework.web.reactive.function.server.ServerRequest.remoteAddress.

Doc from org.springframework.web.reactive.function.server.ServerRequest.remoteAddress.

Get the remote address to which this request is connected, if available.

Annotations
@Override
requestback to summary
public ServerRequest request()

Return the wrapped request.

requestPathback to summary
public RequestPath requestPath()

Overrides default org.springframework.web.reactive.function.server.ServerRequest.requestPath.

Doc from org.springframework.web.reactive.function.server.ServerRequest.requestPath.

Get the request path as a PathContainer.

Annotations
@Override
sessionback to summary
public Mono<WebSession> session()

Implements org.springframework.web.reactive.function.server.ServerRequest.session.

Doc from org.springframework.web.reactive.function.server.ServerRequest.session.

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.

Annotations
@Override
uriback to summary
public URI uri()

Implements org.springframework.web.reactive.function.server.ServerRequest.uri.

Doc from org.springframework.web.reactive.function.server.ServerRequest.uri.

Get the request URI.

Annotations
@Override
uriBuilderback to summary
public UriBuilder uriBuilder()

Implements org.springframework.web.reactive.function.server.ServerRequest.uriBuilder.

Doc from org.springframework.web.reactive.function.server.ServerRequest.uriBuilder.

Get a UriBuilderComponents 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.

Returns:UriBuilder

a URI builder

Annotations
@Override
org.springframework.web.reactive.function.server.support back to summary

public Class ServerRequestWrapper.HeadersWrapper

extends Object
implements Headers
Class Inheritance
  • java.lang.Object
  • org.springframework.web.reactive.function.server.support.ServerRequestWrapper.HeadersWrapper
All Implemented Interfaces
org.springframework.web.reactive.function.server.ServerRequest.Headers

Implementation of the Headers interface that can be subclassed to adapt the headers in a handler filter function. All methods default to calling through to the wrapped headers.

Field Summary

Modifier and TypeField and Description
private final ServerRequest.Headers

Constructor Summary

AccessConstructor and Description
public
HeadersWrapper(ServerRequest.Headers
the headers to wrap
headers
)

Create a new HeadersWrapper that wraps the given request.

Method Summary

Modifier and TypeMethod and Description
public List<MediaType>
accept()

Implements org.springframework.web.reactive.function.server.ServerRequest.Headers.accept.

Get the list of acceptable media types, as specified by the Accept header.

public List<Charset>
acceptCharset()

Implements org.springframework.web.reactive.function.server.ServerRequest.Headers.acceptCharset.

Get the list of acceptable charsets, as specified by the Accept-Charset header.

public List<Locale.LanguageRange>
acceptLanguage()

Implements org.springframework.web.reactive.function.server.ServerRequest.Headers.acceptLanguage.

Get the list of acceptable languages, as specified by the Accept-Language header.

public HttpHeaders
public OptionalLong
contentLength()

Implements org.springframework.web.reactive.function.server.ServerRequest.Headers.contentLength.

Get the length of the body in bytes, as specified by the Content-Length header.

public Optional<MediaType>
contentType()

Implements org.springframework.web.reactive.function.server.ServerRequest.Headers.contentType.

Get the media type of the body, as specified by the Content-Type header.

public List<String>
header(String
the header name
headerName
)

Implements org.springframework.web.reactive.function.server.ServerRequest.Headers.header.

Get the header value(s), if any, for the header with the given name.

public InetSocketAddress
host()

Implements org.springframework.web.reactive.function.server.ServerRequest.Headers.host.

Get the value of the Host header, if available.

public List<HttpRange>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

headersback to summary
private final ServerRequest.Headers headers

Constructor Detail

HeadersWrapperback to summary
public HeadersWrapper(ServerRequest.Headers headers)

Create a new HeadersWrapper that wraps the given request.

Parameters
headers:ServerRequest.Headers

the headers to wrap

Method Detail

acceptback to summary
public List<MediaType> accept()

Implements org.springframework.web.reactive.function.server.ServerRequest.Headers.accept.

Doc from org.springframework.web.reactive.function.server.ServerRequest.Headers.accept.

Get the list of acceptable media types, as specified by the Accept header.

Returns an empty list if the acceptable media types are unspecified.

Annotations
@Override
acceptCharsetback to summary
public List<Charset> acceptCharset()

Implements org.springframework.web.reactive.function.server.ServerRequest.Headers.acceptCharset.

Doc from org.springframework.web.reactive.function.server.ServerRequest.Headers.acceptCharset.

Get the list of acceptable charsets, as specified by the Accept-Charset header.

Annotations
@Override
acceptLanguageback to summary
public List<Locale.LanguageRange> acceptLanguage()

Implements org.springframework.web.reactive.function.server.ServerRequest.Headers.acceptLanguage.

Doc from org.springframework.web.reactive.function.server.ServerRequest.Headers.acceptLanguage.

Get the list of acceptable languages, as specified by the Accept-Language header.

Annotations
@Override
asHttpHeadersback to summary
public HttpHeaders asHttpHeaders()

Implements org.springframework.web.reactive.function.server.ServerRequest.Headers.asHttpHeaders.

Doc from org.springframework.web.reactive.function.server.ServerRequest.Headers.asHttpHeaders.

Get the headers as an instance of HttpHeaders.

Annotations
@Override
contentLengthback to summary
public OptionalLong contentLength()

Implements org.springframework.web.reactive.function.server.ServerRequest.Headers.contentLength.

Doc from org.springframework.web.reactive.function.server.ServerRequest.Headers.contentLength.

Get the length of the body in bytes, as specified by the Content-Length header.

Annotations
@Override
contentTypeback to summary
public Optional<MediaType> contentType()

Implements org.springframework.web.reactive.function.server.ServerRequest.Headers.contentType.

Doc from org.springframework.web.reactive.function.server.ServerRequest.Headers.contentType.

Get the media type of the body, as specified by the Content-Type header.

Annotations
@Override
headerback to summary
public List<String> header(String headerName)

Implements org.springframework.web.reactive.function.server.ServerRequest.Headers.header.

Doc from org.springframework.web.reactive.function.server.ServerRequest.Headers.header.

Get the header value(s), if any, for the header with the given name.

Returns an empty list if no header values are found.

Parameters
headerName:String

the header name

Annotations
@Override
hostback to summary
public InetSocketAddress host()

Implements org.springframework.web.reactive.function.server.ServerRequest.Headers.host.

Doc from org.springframework.web.reactive.function.server.ServerRequest.Headers.host.

Get the value of the Host header, if available.

If the header value does not contain a port, the port in the returned address will be 0.

Annotations
@Override
rangeback to summary
public List<HttpRange> range()

Implements org.springframework.web.reactive.function.server.ServerRequest.Headers.range.

Doc from org.springframework.web.reactive.function.server.ServerRequest.Headers.range.

Get the value of the Range header.

Returns an empty list when the range is unknown.

Annotations
@Override