Interface MutableHttpMessage<B>

  • Type Parameters:
    B - The body type
    All Superinterfaces:
    io.micronaut.core.attr.AttributeHolder, HttpMessage<B>, io.micronaut.core.attr.MutableAttributeHolder
    All Known Subinterfaces:
    MutableHttpRequest<B>, MutableHttpResponse<B>
    All Known Implementing Classes:
    SimpleHttpRequest

    public interface MutableHttpMessage<B>
    extends HttpMessage<B>
    An interface for an HttpMessage that is mutable allowing headers and the message body to be set.
    Since:
    1.0
    • Method Detail

      • body

        <T> MutableHttpMessage<T> body​(T body)
        Sets the body.
        Type Parameters:
        T - The new body type
        Parameters:
        body - The body
        Returns:
        This message
      • headers

        default MutableHttpMessage<B> headers​(java.util.function.Consumer<MutableHttpHeaders> headers)
        Mutate the headers with the given consumer.
        Parameters:
        headers - The headers
        Returns:
        This response
      • header

        default MutableHttpMessage<B> header​(java.lang.CharSequence name,
                                             java.lang.CharSequence value)
        Set a response header.
        Parameters:
        name - The name of the header
        value - The value of the header
        Returns:
        This response
      • basicAuth

        default MutableHttpMessage<B> basicAuth​(java.lang.CharSequence username,
                                                java.lang.CharSequence password)
        Set an HttpHeaders.AUTHORIZATION header, with value: "Basic Base64(username:password)".
        Parameters:
        username - The username part of the credentials
        password - The password part of the credentials
        Returns:
        This response
      • headers

        default MutableHttpMessage<B> headers​(java.util.Map<java.lang.CharSequence,​java.lang.CharSequence> namesAndValues)
        Set multiple headers.
        Parameters:
        namesAndValues - The names and values
        Returns:
        This response
      • contentLength

        default MutableHttpMessage<B> contentLength​(long length)
        Sets the content length.
        Parameters:
        length - The length
        Returns:
        This response
      • contentType

        default MutableHttpMessage<B> contentType​(java.lang.CharSequence contentType)
        Set the response content type.
        Parameters:
        contentType - The content type
        Returns:
        This response
      • contentType

        default MutableHttpMessage<B> contentType​(MediaType mediaType)
        Set the response content type.
        Parameters:
        mediaType - The media type
        Returns:
        This response
      • contentEncoding

        default MutableHttpMessage<B> contentEncoding​(java.lang.CharSequence encoding)
        Sets the content encoding.
        Parameters:
        encoding - The encoding to use
        Returns:
        This message