Interface HttpRequestHeaders

All Known Implementing Classes:
HttpHeadersBuilder

public interface HttpRequestHeaders
  • Method Details

    • add

      HttpRequestHeaders add(String headerName, String headerValue)
      Adds the given name value pair to the set of headers for this request. The given value is added to the list of values for that name.
      Parameters:
      headerName - the header name
      headerValue - the header value
      Returns:
      this instance
    • set

      HttpRequestHeaders set(String headerName, String... headerValues)
      Sets the given name value pair to the set of headers for this request.
      Parameters:
      headerName - the header name
      headerValues - the header values
      Returns:
      this instance
    • remove

      HttpRequestHeaders remove(String headerName)
      Removes the header with the specified name, if present.
      Parameters:
      headerName - the header name
      Returns:
      this instance
    • get

      List<String> get(String headerName)
      Get an immutable list of header values for the given header name, possibly empty.
      Parameters:
      headerName - the header name
      Returns:
      the list of header values, or an empty list
    • getFirst

      default Optional<String> getFirst(String headerName)
      Returns an Optional of the first header value for the given header name, if any.
      Parameters:
      headerName - the header name
      Returns:
      an Optional of first header value or Optional.empty() if none
    • contentType

      default Optional<MediaType> contentType()
      Returns an Optional of media type of the body, as specified by the Content-Type header.
      Returns:
      an Optional of the of the Content-Type header
    • contentType

      default HttpRequestHeaders contentType(MediaType contentType)
      Sets the MediaType of the body, specified by the Content-Type header. Can be null.
      Returns:
      this instance
    • accept

      default HttpRequestHeaders accept(MediaType... acceptableMediaTypes)
      Set the list of acceptable media types, as specified by the Accept header.
      Parameters:
      acceptableMediaTypes - the acceptable media types
      Returns:
      this instance
    • acceptCharset

      default HttpRequestHeaders acceptCharset(Charset... acceptableCharsets)
      Set the list of acceptable charsets, as specified by the Accept-Charset header.
      Parameters:
      acceptableCharsets - the acceptable charsets
      Returns:
      this builder
    • forEach

      void forEach(BiConsumer<String,List<String>> callback)
      Performs the provided callback for each header.