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

pack-priv Class DefaultServerRequest

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.time.Instant, java.util.Collections, .List, .Locale, .Map, .Optional, .OptionalLong, java.util.function.Consumer, .Function, reactor.core.publisher.Flux, .Mono, org.springframework.core.ParameterizedTypeReference, .ResolvableType, org.springframework.core.codec.DecodingException, .Hints, org.springframework.core.io.buffer.DataBuffer, org.springframework.http.HttpCookie, .HttpHeaders, .HttpMethod, .HttpRange, .HttpStatus, .HttpStatusCode, .MediaType, org.springframework.http.codec.HttpMessageReader, org.springframework.http.codec.multipart.Part, org.springframework.http.server.RequestPath, org.springframework.http.server.reactive.ServerHttpRequest, .ServerHttpResponse, org.springframework.lang.Nullable, org.springframework.util.Assert, .MultiValueMap, org.springframework.validation.BindException, .BindingResult, org.springframework.web.bind.WebDataBinder, org.springframework.web.bind.support.WebExchangeDataBinder, org.springframework.web.reactive.function.BodyExtractor, .BodyExtractors, .UnsupportedMediaTypeException, org.springframework.web.server.ServerWebExchange, .ServerWebInputException, .UnsupportedMediaTypeStatusException, .WebSession, org.springframework.web.util.UriBuilder, .UriComponentsBuilder

ServerRequest implementation based on a ServerWebExchange.
Author
Arjen Poutsma
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private static final Function<DecodingException, ServerWebInputException>
private static final Function<UnsupportedMediaTypeException, UnsupportedMediaTypeStatusException>
private final ServerWebExchange
private final ServerRequest.Headers
private final List<HttpMessageReader<?>>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
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
,
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.

private <T> T
bodyInternal(BodyExtractor<T, ? super ServerHttpRequest> extractor, Map<String, Object> 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.

pack-priv static Mono<ServerResponse>
checkNotModified(ServerWebExchange exchange, Instant lastModified, String etag)

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 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 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.

private ServerHttpRequest
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 String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

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:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

DECODING_MAPPERback to summary
private static final Function<DecodingException, ServerWebInputException> DECODING_MAPPER
ERROR_MAPPERback to summary
private static final Function<UnsupportedMediaTypeException, UnsupportedMediaTypeStatusException> ERROR_MAPPER
exchangeback to summary
private final ServerWebExchange exchange
headersback to summary
private final ServerRequest.Headers headers
messageReadersback to summary
private final List<HttpMessageReader<?>> messageReaders

Constructor Detail

DefaultServerRequestback to summary
pack-priv DefaultServerRequest(ServerWebExchange exchange, List<HttpMessageReader<?>> messageReaders)

Method Detail

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, 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
@SuppressWarnings:unchecked
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
bodyInternalback to summary
private <T> T bodyInternal(BodyExtractor<T, ? super ServerHttpRequest> extractor, Map<String, Object> hints)
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
@SuppressWarnings:unchecked
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
checkNotModifiedback to summary
pack-priv static Mono<ServerResponse> checkNotModified(ServerWebExchange exchange, Instant lastModified, String etag)
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
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
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
private ServerHttpRequest 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
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

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 back to summary

private Class DefaultServerRequest.DefaultHeaders

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

Field Summary

Modifier and TypeField and Description
private final HttpHeaders

Constructor Summary

AccessConstructor and Description
private

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>
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

httpHeadersback to summary
private final HttpHeaders httpHeaders

Constructor Detail

DefaultHeadersback to summary
private DefaultHeaders()

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
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override