Interface HttpRequestHeaders

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default HttpRequestHeaders accept​(MediaType... acceptableMediaTypes)
      Set the list of acceptable media types, as specified by the Accept header.
      default HttpRequestHeaders acceptCharset​(java.nio.charset.Charset... acceptableCharsets)
      Set the list of acceptable charsets, as specified by the Accept-Charset header.
      HttpRequestHeaders add​(java.lang.String headerName, java.lang.String headerValue)
      Adds the given name value pair to the set of headers for this request.
      default java.util.Optional<MediaType> contentType()
      Returns an Optional of media type of the body, as specified by the Content-Type header.
      default HttpRequestHeaders contentType​(MediaType contentType)
      Sets the MediaType of the body, specified by the Content-Type header.
      void forEach​(java.util.function.BiConsumer<java.lang.String,​java.util.List<java.lang.String>> callback)
      Performs the provided callback for each header.
      java.util.List<java.lang.String> get​(java.lang.String headerName)
      Get an immutable list of header values for the given header name, possibly empty.
      default java.util.Optional<java.lang.String> getFirst​(java.lang.String headerName)
      Returns an Optional of the first header value for the given header name, if any.
      HttpRequestHeaders remove​(java.lang.String headerName)
      Removes the header with the specified name, if present.
      HttpRequestHeaders set​(java.lang.String headerName, java.lang.String... headerValues)
      Sets the given name value pair to the set of headers for this request.
    • Method Detail

      • add

        HttpRequestHeaders add​(java.lang.String headerName,
                               java.lang.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​(java.lang.String headerName,
                               java.lang.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​(java.lang.String headerName)
        Removes the header with the specified name, if present.
        Parameters:
        headerName - the header name
        Returns:
        this instance
      • get

        java.util.List<java.lang.String> get​(java.lang.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 java.util.Optional<java.lang.String> getFirst​(java.lang.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 java.util.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​(java.nio.charset.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​(java.util.function.BiConsumer<java.lang.String,​java.util.List<java.lang.String>> callback)
        Performs the provided callback for each header.