Interface ServerRequest.Headers

All Known Implementing Classes:
ServerRequestWrapper.HeadersWrapper
Enclosing interface:
ServerRequest

public static interface ServerRequest.Headers
Represents the headers of the HTTP request.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    List<org.springframework.http.MediaType>
    Get the list of acceptable media types, as specified by the Accept header.
    Get the list of acceptable charsets, as specified by the Accept-Charset header.
    Get the list of acceptable languages, as specified by the Accept-Language header.
    org.springframework.http.HttpHeaders
    Get the headers as an instance of HttpHeaders.
    Get the length of the body in bytes, as specified by the Content-Length header.
    Optional<org.springframework.http.MediaType>
    Get the media type of the body, as specified by the Content-Type header.
    default String
    firstHeader(String headerName)
    Get the first header value, if any, for the header with the given name.
    header(String headerName)
    Get the header value(s), if any, for the header with the given name.
    Get the value of the Host header, if available.
    List<org.springframework.http.HttpRange>
    Get the value of the Range header.
  • Method Details

    • accept

      List<org.springframework.http.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.

    • acceptCharset

      List<Charset> acceptCharset()
      Get the list of acceptable charsets, as specified by the Accept-Charset header.
    • acceptLanguage

      List<Locale.LanguageRange> acceptLanguage()
      Get the list of acceptable languages, as specified by the Accept-Language header.
    • contentLength

      OptionalLong contentLength()
      Get the length of the body in bytes, as specified by the Content-Length header.
    • contentType

      Optional<org.springframework.http.MediaType> contentType()
      Get the media type of the body, as specified by the Content-Type header.
    • host

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

    • range

      List<org.springframework.http.HttpRange> range()
      Get the value of the Range 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 with the given name.

      Returns an empty list if no header values are found.

      Parameters:
      headerName - the header name
    • firstHeader

      @Nullable 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 - the header name
      Since:
      5.2.5
    • asHttpHeaders

      org.springframework.http.HttpHeaders asHttpHeaders()
      Get the headers as an instance of HttpHeaders.