public static class ServerRequestWrapper.HeadersWrapper extends Object implements ServerRequest.Headers
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.Constructor and Description |
---|
HeadersWrapper(ServerRequest.Headers headers)
Create a new
HeadersWrapper that wraps the given request. |
Modifier and Type | Method and Description |
---|---|
List<MediaType> |
accept()
Get the list of acceptable media types, as specified by the
Accept
header. |
List<Charset> |
acceptCharset()
Get the list of acceptable charsets, as specified by the
Accept-Charset header. |
List<Locale.LanguageRange> |
acceptLanguage()
Get the list of acceptable languages, as specified by the
Accept-Language header. |
HttpHeaders |
asHttpHeaders()
Get the headers as an instance of
HttpHeaders . |
OptionalLong |
contentLength()
Get the length of the body in bytes, as specified by the
Content-Length header. |
Optional<MediaType> |
contentType()
Get the media type of the body, as specified by the
Content-Type header. |
List<String> |
header(String headerName)
Get the header value(s), if any, for the header with the given name.
|
InetSocketAddress |
host()
Get the value of the
Host header, if available. |
List<HttpRange> |
range()
Get the value of the
Range header. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
firstHeader
public HeadersWrapper(ServerRequest.Headers headers)
HeadersWrapper
that wraps the given request.headers
- the headers to wrappublic List<MediaType> accept()
ServerRequest.Headers
Accept
header.
Returns an empty list if the acceptable media types are unspecified.
accept
in interface ServerRequest.Headers
public List<Charset> acceptCharset()
ServerRequest.Headers
Accept-Charset
header.acceptCharset
in interface ServerRequest.Headers
public List<Locale.LanguageRange> acceptLanguage()
ServerRequest.Headers
Accept-Language
header.acceptLanguage
in interface ServerRequest.Headers
public OptionalLong contentLength()
ServerRequest.Headers
Content-Length
header.contentLength
in interface ServerRequest.Headers
public Optional<MediaType> contentType()
ServerRequest.Headers
Content-Type
header.contentType
in interface ServerRequest.Headers
public InetSocketAddress host()
ServerRequest.Headers
Host
header, if available.
If the header value does not contain a port, the
port in the returned address will
be 0
.
host
in interface ServerRequest.Headers
public List<HttpRange> range()
ServerRequest.Headers
Range
header.
Returns an empty list when the range is unknown.
range
in interface ServerRequest.Headers
public List<String> header(String headerName)
ServerRequest.Headers
Returns an empty list if no header values are found.
header
in interface ServerRequest.Headers
headerName
- the header namepublic HttpHeaders asHttpHeaders()
ServerRequest.Headers
HttpHeaders
.asHttpHeaders
in interface ServerRequest.Headers