接口 ServerRequest.Headers
- 封闭接口:
- ServerRequest
public static interface ServerRequest.Headers
Represents the headers of the HTTP request.
方法概要
所有方法 实例方法 抽象方法 默认方法 修饰符和类型 方法 说明 List<MediaType>
accept()
Get the list of acceptable media types, as specified by theAccept
header.List<Charset>
acceptCharset()
Get the list of acceptable charsets, as specified by theAccept-Charset
header.List<Locale.LanguageRange>
acceptLanguage()
Get the list of acceptable languages, as specified by theAccept-Language
header.HttpHeaders
asHttpHeaders()
Get the headers as an instance ofHttpHeaders
.OptionalLong
contentLength()
Get the length of the body in bytes, as specified by theContent-Length
header.Optional<MediaType>
contentType()
Get the media type of the body, as specified by theContent-Type
header.default String
firstHeader(String headerName)
Get the first header value, if any, for the header for the given name.List<String>
header(String headerName)
Get the header value(s), if any, for the header of the given name.InetSocketAddress
host()
Get the value of theHost
header, if available.List<HttpRange>
range()
Get the value of theRange
header.
方法详细资料
accept
List<MediaType> accept()
Get the list of acceptable media types, as specified by theAccept
header.Returns an empty list if the acceptable media types are unspecified.
acceptCharset
List<Charset> acceptCharset()
Get the list of acceptable charsets, as specified by theAccept-Charset
header.
acceptLanguage
List<Locale.LanguageRange> acceptLanguage()
Get the list of acceptable languages, as specified by theAccept-Language
header.
contentLength
OptionalLong contentLength()
Get the length of the body in bytes, as specified by theContent-Length
header.
contentType
Optional<MediaType> contentType()
Get the media type of the body, as specified by theContent-Type
header.
host
@Nullable InetSocketAddress host()
Get the value of theHost
header, if available.If the header value does not contain a port, the port in the returned address will be
0
.
range
List<HttpRange> range()
Get the value of theRange
header.Returns an empty list when the range is unknown.
header
List<String> header(String headerName)
Get the header value(s), if any, for the header of the given name.Returns an empty list if no header values are found.
- 参数:
headerName
- the header name
firstHeader
@Nullable default String firstHeader(String headerName)
Get the first header value, if any, for the header for the given name.Returns
null
if no header values are found.- 参数:
headerName
- the header name- 从以下版本开始:
- 5.2.5
asHttpHeaders
HttpHeaders asHttpHeaders()
Get the headers as an instance ofHttpHeaders
.