Interface HttpMessage<B>

Type Parameters:
B - The body type
All Superinterfaces:
AttributeHolder, MutableAttributeHolder
All Known Subinterfaces:
ByteBodyHttpResponse<B>, FullHttpRequest<B>, HttpRequest<B>, HttpResponse<B>, MutableHttpMessage<B>, MutableHttpRequest<B>, MutableHttpResponse<B>, PushCapableHttpRequest<B>, ServerHttpRequest<B>
All Known Implementing Classes:
AbstractNettyHttpRequest, ByteBodyHttpResponseWrapper, FullNettyClientHttpResponse, HttpMessageWrapper, HttpRequestWrapper, HttpResponseAdapter, HttpResponseWrapper, MutableHttpRequestWrapper, NettyClientHttpRequest, NettyHttpRequest, NettyMutableHttpResponse, SimpleHttpRequest

public interface HttpMessage<B> extends MutableAttributeHolder
Common interface for HTTP messages.
Since:
1.0
Author:
Graeme Rocher
See Also:
  • Method Details

    • getHeaders

      @NonNull HttpHeaders getHeaders()
      Returns:
      The HttpHeaders object
    • getAttributes

      @NonNull MutableConvertibleValues<Object> getAttributes()

      A MutableConvertibleValues of the attributes for this HTTP message.

      Attributes are designed for internal data sharing and hence are isolated from headers and parameters which are client supplied

      Specified by:
      getAttributes in interface AttributeHolder
      Specified by:
      getAttributes in interface MutableAttributeHolder
      Returns:
      The attributes of the message
    • getBody

      @NonNull Optional<B> getBody()
      Returns:
      The request body
    • getBodyWriter

      default Optional<MessageBodyWriter<B>> getBodyWriter()
      Returns:
      The body writer.
      Since:
      4.0.0
    • getCharacterEncoding

      default @NonNull Charset getCharacterEncoding()
      Returns:
      The request character encoding. Defaults to StandardCharsets.UTF_8
    • setAttribute

      default @NonNull HttpMessage<B> setAttribute(@NonNull CharSequence name, Object value)
      Description copied from interface: MutableAttributeHolder
      Sets an attribute on the message.
      Specified by:
      setAttribute in interface MutableAttributeHolder
      Parameters:
      name - The name of the attribute
      value - The value of the attribute
      Returns:
      This message
    • getBody

      default <T> @NonNull Optional<T> getBody(@NonNull Argument<T> type)
      Return the body as the given type.
      Type Parameters:
      T - The generic type
      Parameters:
      type - The type of the body
      Returns:
      An Optional of the type or Optional.empty() if the body cannot be returned as the given type
    • getBody

      default <T> @NonNull Optional<T> getBody(@NonNull ArgumentConversionContext<T> conversionContext)
      Return the body, will use the provided conversion context if needed.
      Type Parameters:
      T - The generic type
      Parameters:
      conversionContext - The body conversion context
      Returns:
      An Optional of the type or Optional.empty() if the body cannot be returned as the given type
      Since:
      4.0.0
    • getBody

      default <T> @NonNull Optional<T> getBody(@NonNull Class<T> type)
      Return the body as the given type.
      Type Parameters:
      T - The generic type
      Parameters:
      type - The type of the body
      Returns:
      An Optional of the type or Optional.empty() if the body cannot be returned as the given type
    • getLocale

      default @NonNull Optional<Locale> getLocale()
      Returns:
      The locale of the message
    • getContentLength

      default long getContentLength()
      Returns:
      The value of the Content-Length header or -1L if none specified
    • getContentType

      default @NonNull Optional<MediaType> getContentType()
      The request or response content type.
      Returns:
      The content type