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

public Interface ServerRequest

Known Direct Implementers
org.springframework.web.reactive.function.server.support.ServerRequestWrapper, org.springframework.web.reactive.function.server.DefaultServerRequest, org.springframework.web.reactive.function.server.RequestPredicates.DelegatingServerRequest
Imports
java.net.InetSocketAddress, .URI, java.nio.charset.Charset, java.security.Principal, java.time.Instant, java.util.List, .Locale, .Map, .Optional, .OptionalLong, java.util.function.Consumer, reactor.core.publisher.Flux, .Mono, org.springframework.core.ParameterizedTypeReference, org.springframework.core.io.buffer.DataBuffer, org.springframework.http.HttpCookie, .HttpHeaders, .HttpMethod, .HttpRange, .MediaType, org.springframework.http.codec.HttpMessageReader, org.springframework.http.codec.json.Jackson2CodecSupport, org.springframework.http.codec.multipart.Part, org.springframework.http.server.PathContainer, .RequestPath, org.springframework.http.server.reactive.ServerHttpRequest, org.springframework.lang.Nullable, org.springframework.util.Assert, .CollectionUtils, .MultiValueMap, org.springframework.validation.BindException, org.springframework.web.bind.WebDataBinder, org.springframework.web.reactive.function.BodyExtractor, org.springframework.web.server.ServerWebExchange, .WebSession, org.springframework.web.util.UriBuilder

Represents a server-side HTTP request, as handled by a HandlerFunction.

Access to headers and body is offered by Headers and body(BodyExtractor), respectively.

Authors
Arjen Poutsma, Sebastien Deleuze
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
ServerRequest.Builder

Defines a builder for a request.

public static interface
ServerRequest.Headers

Represents the headers of the HTTP request.

Method Summary

Modifier and TypeMethod and Description
public default Optional<Object>

Returns:

the attribute value
attribute
(String
the attribute name
name
)

Get the request attribute value if present.

public Map<String, Object>

Returns:

the request attributes
attributes
()

Get a mutable map of request attributes.

public default <
the type to bind to
T
>
Mono<T>

Returns:

a mono containing either a constructed and bound instance of bindType, or a BindException in case of binding errors
bind
(Class<T>
the type of class to bind this request to
bindType
)

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

public <
the type to bind to
T
>
Mono<T>

Returns:

a mono containing either a constructed and bound instance of bindType, or a BindException in case of binding errors
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
)

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

public <
the type of the body returned
T
>
T

Returns:

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

Extract the body with the given BodyExtractor.

public <
the type of the body returned
T
>
T

Returns:

the extracted body
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
)

Extract the body with the given BodyExtractor and hints.

public <
the element type
T
>
Flux<T>

Returns:

the body as a flux
bodyToFlux
(Class<? extends T>
the class of element in the Flux
elementClass
)

Extract the body to a Flux.

public <
the element type
T
>
Flux<T>

Returns:

a flux containing the body of the given type T
bodyToFlux
(ParameterizedTypeReference<T>
a type reference describing the expected request body type
typeReference
)

Extract the body to a Flux.

public <
the element type
T
>
Mono<T>

Returns:

the body as a mono
bodyToMono
(Class<? extends T>
the class of element in the Mono
elementClass
)

Extract the body to a Mono.

public <
the element type
T
>
Mono<T>

Returns:

a mono containing the body of the given type T
bodyToMono
(ParameterizedTypeReference<T>
a type reference describing the expected response request type
typeReference
)

Extract the body to a Mono.

public default Mono<ServerResponse>

Returns:

a corresponding response if the request qualifies as not modified, or an empty result otherwise
checkNotModified
(Instant
the last-modified timestamp that the application determined for the underlying resource
lastModified
)

Check whether the requested resource has been modified given the supplied last-modified timestamp (as determined by the application).

public default Mono<ServerResponse>

Returns:

a corresponding response if the request qualifies as not modified, or an empty result otherwise
checkNotModified
(String
the entity tag that the application determined for the underlying resource. This parameter will be padded with quotes (") if necessary. Use an empty string "" for no value.
etag
)

Check whether the requested resource has been modified given the supplied ETag (entity tag), as determined by the application.

public default Mono<ServerResponse>

Returns:

a corresponding response if the request qualifies as not modified, or an empty result otherwise.
checkNotModified
(Instant
the last-modified timestamp that the application determined for the underlying resource
lastModified
,
String
the entity tag that the application determined for the underlying resource. This parameter will be padded with quotes (") if necessary. Use an empty string "" for no value.
etag
)

Check whether the requested resource has been modified given the supplied ETag (entity tag) and last-modified timestamp, as determined by the application.

public MultiValueMap<String, HttpCookie>
cookies()

Get the cookies of this request.

public static ServerRequest

Returns:

the created ServerRequest
create
(ServerWebExchange
the exchange
exchange
,
List<HttpMessageReader<?>>
the message readers
messageReaders
)

Create a new ServerRequest based on the given ServerWebExchange and message readers.

public ServerWebExchange
exchange()

Get the web exchange that this request is based on.

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

public static ServerRequest.Builder

Returns:

the created builder
from
(ServerRequest
the request to copy the message readers, method name, URI, headers, and attributes from
other
)

Create a builder with the message readers, method name, URI, headers, cookies, and attributes of the given request.

public ServerRequest.Headers
headers()

Get the headers of this request.

public Optional<InetSocketAddress>
localAddress()

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

public List<HttpMessageReader<?>>
messageReaders()

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

public HttpMethod
method()

Get the HTTP method.

public String

Returns:

the HTTP method as a String
methodName
()
Deprecated since 6.0. as of 6.0, in favor of method()

Get the name of the HTTP method.

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

public default String
path()

Get the request path.

public default PathContainer
pathContainer()
Deprecated as of 5.3, in favor on requestPath()

Get the request path as a PathContainer.

public default String

Returns:

the variable value
pathVariable
(String
the variable name
name
)

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

public Map<String, String>
pathVariables()

Get all path variables for this request.

public Mono<? extends Principal>
principal()

Get the authenticated user for the request, if any.

public default Optional<String>

Returns:

the parameter value
queryParam
(String
the parameter name
name
)

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

public MultiValueMap<String, String>
queryParams()

Get all query parameters for this request.

public Optional<InetSocketAddress>
remoteAddress()

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

public default RequestPath
requestPath()

Get the request path as a PathContainer.

public Mono<WebSession>
session()

Get the web session for this request.

public URI
uri()

Get the request URI.

public UriBuilder

Returns:

a URI builder
uriBuilder
()

Get a UriBuilderComponents from the URI associated with this ServerRequest.

Method Detail

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

Get the request attribute value if present.

Parameters
name:String

the attribute name

Returns:Optional<Object>

the attribute value

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

Get a mutable map of request attributes.

Returns:Map<String, Object>

the request attributes

bindback to summary
public default <T> Mono<T> bind(Class<T> bindType)

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

Since
6.1
bindback to summary
public <T> Mono<T> bind(Class<T> bindType, Consumer<WebDataBinder> dataBinderCustomizer)

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

Since
6.1
bodyback to summary
public <T> T body(BodyExtractor<T, ? super ServerHttpRequest> extractor)

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

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

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

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

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

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

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

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

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

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

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

checkNotModifiedback to summary
public default Mono<ServerResponse> checkNotModified(Instant lastModified)

Check whether the requested resource has been modified given the supplied last-modified timestamp (as determined by the application).

If not modified, this method returns a response with corresponding status code and headers, otherwise an empty result.

Typical usage:

 public Mono<ServerResponse> myHandleMethod(ServerRequest request) {
   Instant lastModified = // application-specific calculation
	 return request.checkNotModified(lastModified)
	   .switchIfEmpty(Mono.defer(() -> {
	     // further request processing, actually building content
		 return ServerResponse.ok().body(...);
	   }));
 }

This method works with conditional GET/HEAD requests, but also with conditional POST/PUT/DELETE requests.

Note

you can use either this #checkNotModified(Instant) method; or checkNotModified(String). If you want to enforce both a strong entity tag and a Last-Modified value, as recommended by the HTTP specification, then you should use checkNotModified(Instant, String).

Parameters
lastModified:Instant

the last-modified timestamp that the application determined for the underlying resource

Returns:Mono<ServerResponse>

a corresponding response if the request qualifies as not modified, or an empty result otherwise

Since
5.2.5
checkNotModifiedback to summary
public default Mono<ServerResponse> checkNotModified(String etag)

Check whether the requested resource has been modified given the supplied ETag (entity tag), as determined by the application.

If not modified, this method returns a response with corresponding status code and headers, otherwise an empty result.

Typical usage:

 public Mono<ServerResponse> myHandleMethod(ServerRequest request) {
   String eTag = // application-specific calculation
	 return request.checkNotModified(eTag)
	   .switchIfEmpty(Mono.defer(() -> {
	     // further request processing, actually building content
		 return ServerResponse.ok().body(...);
	   }));
 }

This method works with conditional GET/HEAD requests, but also with conditional POST/PUT/DELETE requests.

Note

you can use either this checkNotModified(Instant) method; or #checkNotModified(String). If you want to enforce both a strong entity tag and a Last-Modified value, as recommended by the HTTP specification, then you should use checkNotModified(Instant, String).

Parameters
etag:String

the entity tag that the application determined for the underlying resource. This parameter will be padded with quotes (") if necessary. Use an empty string "" for no value.

Returns:Mono<ServerResponse>

a corresponding response if the request qualifies as not modified, or an empty result otherwise

Since
5.2.5
checkNotModifiedback to summary
public default Mono<ServerResponse> checkNotModified(Instant lastModified, String etag)

Check whether the requested resource has been modified given the supplied ETag (entity tag) and last-modified timestamp, as determined by the application.

If not modified, this method returns a response with corresponding status code and headers, otherwise an empty result.

Typical usage:

 public Mono<ServerResponse> myHandleMethod(ServerRequest request) {
   Instant lastModified = // application-specific calculation
   String eTag = // application-specific calculation
	 return request.checkNotModified(lastModified, eTag)
	   .switchIfEmpty(Mono.defer(() -> {
	     // further request processing, actually building content
		 return ServerResponse.ok().body(...);
	   }));
 }

This method works with conditional GET/HEAD requests, but also with conditional POST/PUT/DELETE requests.

Parameters
lastModified:Instant

the last-modified timestamp that the application determined for the underlying resource

etag:String

the entity tag that the application determined for the underlying resource. This parameter will be padded with quotes (") if necessary. Use an empty string "" for no value.

Returns:Mono<ServerResponse>

a corresponding response if the request qualifies as not modified, or an empty result otherwise.

Since
5.2.5
cookiesback to summary
public MultiValueMap<String, HttpCookie> cookies()

Get the cookies of this request.

createback to summary
public static ServerRequest create(ServerWebExchange exchange, List<HttpMessageReader<?>> messageReaders)

Create a new ServerRequest based on the given ServerWebExchange and message readers.

Parameters
exchange:ServerWebExchange

the exchange

messageReaders:List<HttpMessageReader<?>>

the message readers

Returns:ServerRequest

the created ServerRequest

exchangeback to summary
public ServerWebExchange 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.

Since
5.1
formDataback to summary
public 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.

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.

fromback to summary
public static ServerRequest.Builder from(ServerRequest other)

Create a builder with the message readers, method name, URI, headers, cookies, and attributes of the given request.

Parameters
other:ServerRequest

the request to copy the message readers, method name, URI, headers, and attributes from

Returns:ServerRequest.Builder

the created builder

Since
5.1
headersback to summary
public ServerRequest.Headers headers()

Get the headers of this request.

localAddressback to summary
public Optional<InetSocketAddress> localAddress()

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

Since
5.2.3
messageReadersback to summary
public List<HttpMessageReader<?>> messageReaders()

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

Since
5.1
methodback to summary
public HttpMethod method()

Get the HTTP method.

methodNameback to summary
public String methodName()

Deprecated

since 6.0.

as of 6.0, in favor of method()

Get the name of the HTTP method.

Returns:String

the HTTP method as a String

Annotations
@Deprecated
since:6.0
multipartDataback to summary
public 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.

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.

pathback to summary
public default String path()

Get the request path.

pathContainerback to summary
public default PathContainer pathContainer()

Deprecated

as of 5.3, in favor on requestPath()

Get the request path as a PathContainer.

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

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

Parameters
name:String

the variable name

Returns:String

the variable value

Exceptions
IllegalArgumentException:
if there is no path variable with the given name
pathVariablesback to summary
public Map<String, String> pathVariables()

Get all path variables for this request.

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

Get the authenticated user for the request, if any.

queryParamback to summary
public default Optional<String> queryParam(String name)

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

Parameters
name:String

the parameter name

Returns:Optional<String>

the parameter value

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

Get all query parameters for this request.

remoteAddressback to summary
public Optional<InetSocketAddress> remoteAddress()

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

Since
5.1
requestPathback to summary
public default RequestPath requestPath()

Get the request path as a PathContainer.

Since
5.3
sessionback to summary
public Mono<WebSession> 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.

uriback to summary
public URI uri()

Get the request URI.

uriBuilderback to summary
public UriBuilder 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

org.springframework.web.reactive.function.server back to summary

public Interface ServerRequest.Builder

Known Direct Implementers
org.springframework.web.reactive.function.server.DefaultServerRequestBuilder

Defines a builder for a request.
Since
5.1

Method Summary

Modifier and TypeMethod and Description
public ServerRequest.Builder

Returns:

this builder
attribute
(String
the attribute name
name
,
Object
the attribute value
value
)

Add an attribute with the given name and value.

public ServerRequest.Builder

Returns:

this builder
attributes
(Consumer<Map<String, Object>>
a function that consumes the attributes map
attributesConsumer
)

Manipulate this request's attributes with the given consumer.

public ServerRequest.Builder

Returns:

this builder
body
(Flux<DataBuffer>
the new body
body
)

Set the body of the request.

public ServerRequest.Builder

Returns:

this builder
body
(String
the new body
body
)

Set the body of the request to the UTF-8 encoded bytes of the given string.

public ServerRequest

Returns:

the built request
build
()

Build the request.

public ServerRequest.Builder

Returns:

this builder
contextPath
(String
the new context path
contextPath
)

Set the context path of the request.

public ServerRequest.Builder

Returns:

this builder
cookie
(String
the cookie name
name
,
String...
the cookie value(s)
values
)

Add a cookie with the given name and value(s).

public ServerRequest.Builder

Returns:

this builder
cookies
(Consumer<MultiValueMap<String, HttpCookie>>
a function that consumes the cookies map
cookiesConsumer
)

Manipulate this request's cookies with the given consumer.

public ServerRequest.Builder

Returns:

this builder
header
(String
the header name
headerName
,
String...
the header value(s)
headerValues
)

Add the given header value(s) under the given name.

public ServerRequest.Builder

Returns:

this builder
headers
(Consumer<HttpHeaders>
a function that consumes the HttpHeaders
headersConsumer
)

Manipulate this request's headers with the given consumer.

public ServerRequest.Builder

Returns:

this builder
method
(HttpMethod
the new method
method
)

Set the method of the request.

public ServerRequest.Builder

Returns:

this builder
uri
(URI
the new URI
uri
)

Set the URI of the request.

Method Detail

attributeback to summary
public ServerRequest.Builder attribute(String name, Object value)

Add an attribute with the given name and value.

Parameters
name:String

the attribute name

value:Object

the attribute value

Returns:ServerRequest.Builder

this builder

attributesback to summary
public ServerRequest.Builder attributes(Consumer<Map<String, Object>> attributesConsumer)

Manipulate this request's attributes with the given consumer.

The map provided to the consumer is "live", so that the consumer can be used to overwrite existing attributes, remove attributes, or use any of the other Map methods.

Parameters
attributesConsumer:Consumer<Map<String, Object>>

a function that consumes the attributes map

Returns:ServerRequest.Builder

this builder

bodyback to summary
public ServerRequest.Builder body(Flux<DataBuffer> body)

Set the body of the request.

Calling this methods will release the existing body of the builder.

Parameters
body:Flux<DataBuffer>

the new body

Returns:ServerRequest.Builder

this builder

bodyback to summary
public ServerRequest.Builder body(String body)

Set the body of the request to the UTF-8 encoded bytes of the given string.

Calling this methods will release the existing body of the builder.

Parameters
body:String

the new body

Returns:ServerRequest.Builder

this builder

buildback to summary
public ServerRequest build()

Build the request.

Returns:ServerRequest

the built request

contextPathback to summary
public ServerRequest.Builder contextPath(String contextPath)

Set the context path of the request.

Parameters
contextPath:String

the new context path

Returns:ServerRequest.Builder

this builder

Since
5.3.23
cookieback to summary
public ServerRequest.Builder cookie(String name, String... values)

Add a cookie with the given name and value(s).

Parameters
name:String

the cookie name

values:String[]

the cookie value(s)

Returns:ServerRequest.Builder

this builder

cookiesback to summary
public ServerRequest.Builder cookies(Consumer<MultiValueMap<String, HttpCookie>> cookiesConsumer)

Manipulate this request's cookies with the given consumer.

The map provided to the consumer is "live", so that the consumer can be used to overwrite existing cookies, remove cookies, or use any of the other MultiValueMap methods.

Parameters
cookiesConsumer:Consumer<MultiValueMap<String, HttpCookie>>

a function that consumes the cookies map

Returns:ServerRequest.Builder

this builder

headerback to summary
public ServerRequest.Builder header(String headerName, String... headerValues)

Add the given header value(s) under the given name.

Parameters
headerName:String

the header name

headerValues:String[]

the header value(s)

Returns:ServerRequest.Builder

this builder

See Also
HttpHeaders#add(String, String)
headersback to summary
public ServerRequest.Builder headers(Consumer<HttpHeaders> headersConsumer)

Manipulate this request's headers with the given consumer.

The headers provided to the consumer are "live", so that the consumer can be used to overwrite existing header values, remove values, or use any of the other HttpHeaders methods.

Parameters
headersConsumer:Consumer<HttpHeaders>

a function that consumes the HttpHeaders

Returns:ServerRequest.Builder

this builder

methodback to summary
public ServerRequest.Builder method(HttpMethod method)

Set the method of the request.

Parameters
method:HttpMethod

the new method

Returns:ServerRequest.Builder

this builder

uriback to summary
public ServerRequest.Builder uri(URI uri)

Set the URI of the request.

Parameters
uri:URI

the new URI

Returns:ServerRequest.Builder

this builder

org.springframework.web.reactive.function.server back to summary

public Interface ServerRequest.Headers

Known Direct Implementers
org.springframework.web.reactive.function.server.support.ServerRequestWrapper.HeadersWrapper, org.springframework.web.reactive.function.server.DefaultServerRequest.DefaultHeaders

Represents the headers of the HTTP request.
See Also
ServerRequest#headers()

Method Summary

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

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

public List<Charset>
acceptCharset()

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

public List<Locale.LanguageRange>
acceptLanguage()

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

public HttpHeaders
asHttpHeaders()

Get the headers as an instance of HttpHeaders.

public OptionalLong
contentLength()

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

public Optional<MediaType>
contentType()

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

public default String
firstHeader(String
the header name
headerName
)

Get the first header value, if any, for the header with the given name.

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

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

public InetSocketAddress
host()

Get the value of the Host header, if available.

public List<HttpRange>
range()

Get the value of the Range header.

Method Detail

acceptback to summary
public List<MediaType> 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.

acceptCharsetback to summary
public List<Charset> acceptCharset()

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

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

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

asHttpHeadersback to summary
public HttpHeaders asHttpHeaders()

Get the headers as an instance of HttpHeaders.

contentLengthback to summary
public OptionalLong contentLength()

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

contentTypeback to summary
public Optional<MediaType> contentType()

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

firstHeaderback to summary
public default String firstHeader(String headerName)

Get the first header value, if any, for the header with the given name.

Returns null if no header values are found.

Parameters
headerName:String

the header name

Annotations
@Nullable
Since
5.2.5
headerback to summary
public List<String> header(String headerName)

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

hostback to summary
public InetSocketAddress 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
@Nullable
rangeback to summary
public List<HttpRange> range()

Get the value of the Range header.

Returns an empty list when the range is unknown.