Class HttpResponse.BodyHandlers

java.lang.Object
dev.gmitch215.bytebox.net.http.HttpResponse.BodyHandlers
Enclosing class:
HttpResponse<T>

public static final class HttpResponse.BodyHandlers extends Object
The ways to read a body.
  • Method Details

    • ofString

      public static HttpResponse.BodyHandler<String> ofString()
      Returns a handler reading the body as UTF-8 text.
      Returns:
      a handler reading the body as UTF-8 text
    • ofString

      public static HttpResponse.BodyHandler<String> ofString(Charset charset)
      Reads the body as text.
      Parameters:
      charset - how to decode it
      Returns:
      the handler
    • ofByteArray

      public static HttpResponse.BodyHandler<byte[]> ofByteArray()
      Returns a handler reading the body as bytes.
      Returns:
      a handler reading the body as bytes
    • ofInputStream

      public static HttpResponse.BodyHandler<InputStream> ofInputStream()
      Returns a handler reading the body as a stream over bytes already in hand.
      Returns:
      a handler reading the body as a stream over bytes already in hand
    • discarding

      public static HttpResponse.BodyHandler<Void> discarding()
      Returns a handler that reads the body and throws it away.
      Returns:
      a handler that reads the body and throws it away