Interface HttpContent

All Superinterfaces:
HttpObject
All Known Subinterfaces:
FullHttpMessage, FullHttpRequest, FullHttpResponse, LastHttpContent
All Known Implementing Classes:
DefaultFullHttpRequest, DefaultFullHttpResponse, DefaultHttpContent, DefaultLastHttpContent, HttpCache.Answer, ServerReplay.Replayed

public sealed interface HttpContent extends HttpObject permits LastHttpContent, DefaultHttpContent
A piece of an HTTP message body.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Returns the live backing array of body bytes, not a copy.
    default String
    Returns this body piece decoded as UTF-8.
    default String
    Decodes this body piece as text.
    default int
    Returns the number of bytes in this body piece.
    setContent(byte[] content)
    Replaces the body bytes of this piece.
  • Method Details

    • content

      byte[] content()
      Returns the live backing array of body bytes, not a copy.
      Returns:
      the live backing array of body bytes, not a copy
    • setContent

      HttpContent setContent(byte[] content)
      Replaces the body bytes of this piece.
      Parameters:
      content - new backing array, retained without copying
      Returns:
      this content object
    • contentLength

      default int contentLength()
      Returns the number of bytes in this body piece.
      Returns:
      the number of bytes in this body piece
    • contentAsString

      default String contentAsString(Charset charset)
      Decodes this body piece as text.
      Parameters:
      charset - character encoding to use
      Returns:
      the decoded text
    • contentAsString

      default String contentAsString()
      Returns this body piece decoded as UTF-8.
      Returns:
      this body piece decoded as UTF-8