Class HttpClientResponse

java.lang.Object
io.vertx.mutiny.core.http.HttpClientResponse
All Implemented Interfaces:
MutinyDelegate, HttpResponseHead, ReadStream<io.vertx.core.buffer.Buffer>, StreamBase

public class HttpClientResponse extends Object implements HttpResponseHead, ReadStream<io.vertx.core.buffer.Buffer>, MutinyDelegate
Represents a client-side HTTP response.

Vert.x provides you with one of these via the handler that was provided when creating the HttpClientRequest or that was set on the HttpClientRequest instance.

It implements ReadStream so it can be used with Pipe to pipe data with flow control.

NOTE: This class has been automatically generated from the original non Mutiny-ified interface.

Author:
Tim Fox
See Also:
  • HttpClientResponse
  • Field Details

  • Constructor Details

    • HttpClientResponse

      public HttpClientResponse(io.vertx.core.http.HttpClientResponse delegate)
      Create a new instance of HttpClientResponse delegating to the given (non-null) instance of HttpClientResponse.
    • HttpClientResponse

      public HttpClientResponse(Object delegate)
  • Method Details

    • getDelegate

      public io.vertx.core.http.HttpClientResponse getDelegate()
      Get the delegate instance.

      This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.

      Specified by:
      getDelegate in interface HttpResponseHead
      Specified by:
      getDelegate in interface MutinyDelegate
      Specified by:
      getDelegate in interface ReadStream<io.vertx.core.buffer.Buffer>
      Specified by:
      getDelegate in interface StreamBase
      Returns:
      the delegate instance
    • body

      @CheckReturnValue public io.smallrye.mutiny.Uni<io.vertx.core.buffer.Buffer> body()
      Convenience method for receiving the entire request body in one piece.

      This saves you having to manually set a dataHandler and an endHandler and append the chunks of the body until the whole body received. Don't use this if your request body is large - you could potentially run out of RAM.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • HttpClientResponse.body()
    • bodyAndAwait

      public io.vertx.core.buffer.Buffer bodyAndAwait()
      Convenience method for receiving the entire request body in one piece.

      This saves you having to manually set a dataHandler and an endHandler and append the chunks of the body until the whole body received. Don't use this if your request body is large - you could potentially run out of RAM.

      Unlike the bare Vert.x variant, this method returns a Buffer. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Returns:
      The operation result
      See Also:
      • HttpClientResponse.body()
    • bodyAndForget

      public HttpClientResponse bodyAndForget()
      Convenience method for receiving the entire request body in one piece.

      This saves you having to manually set a dataHandler and an endHandler and append the chunks of the body until the whole body received. Don't use this if your request body is large - you could potentially run out of RAM.

      Unlike the bare Vert.x variant, this method ignores the Buffer result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • HttpClientResponse.body()
    • end

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> end()
      Returns a uni signaling when the response has been fully received successfully or failed.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • HttpClientResponse.end()
    • endAndAwait

      public void endAndAwait()
      Returns a underlying uni signaling when the response has been fully received successfully or failed.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      See Also:
      • HttpClientResponse.end()
    • endAndForget

      public HttpClientResponse endAndForget()
      Returns a underlying uni signaling when the response has been fully received successfully or failed.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • HttpClientResponse.end()
    • pipeTo

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> pipeTo(WriteStream<io.vertx.core.buffer.Buffer> arg0)
      Pipe this ReadStream to the WriteStream.

      Elements emitted by this stream will be written to the write stream until this stream ends or fails.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Specified by:
      pipeTo in interface ReadStream<io.vertx.core.buffer.Buffer>
      Parameters:
      dst - the destination write stream
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • io.vertx.core.http.HttpClientResponse#pipeTo(WriteStream)
    • pipeToAndAwait

      public void pipeToAndAwait(WriteStream<io.vertx.core.buffer.Buffer> arg0)
      Pipe this ReadStream to the WriteStream.

      Elements emitted by this stream will be written to the write stream until this stream ends or fails.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      dst - the destination write stream
      See Also:
      • io.vertx.core.http.HttpClientResponse#pipeTo(WriteStream)
    • pipeToAndForget

      public HttpClientResponse pipeToAndForget(WriteStream<io.vertx.core.buffer.Buffer> arg0)
      Pipe this ReadStream to the WriteStream.

      Elements emitted by this stream will be written to the write stream until this stream ends or fails.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Parameters:
      dst - the destination write stream
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • io.vertx.core.http.HttpClientResponse#pipeTo(WriteStream)
    • fetch

      public HttpClientResponse fetch(long amount)
      Description copied from interface: ReadStream
      Fetch the specified amount of elements. If the ReadStream has been paused, reading will recommence with the specified amount of items, otherwise the specified amount will be added to the current stream demand.
      Specified by:
      fetch in interface ReadStream<io.vertx.core.buffer.Buffer>
      Returns:
      a reference to this, so the API can be used fluently
    • resume

      public HttpClientResponse resume()
      Description copied from interface: ReadStream
      Resume reading, and sets the buffer in flowing mode.

      If the ReadStream has been paused, reading will recommence on it.

      Specified by:
      resume in interface ReadStream<io.vertx.core.buffer.Buffer>
      Returns:
      a reference to this, so the API can be used fluently
    • exceptionHandler

      public HttpClientResponse exceptionHandler(Consumer<Throwable> handler)
      Description copied from interface: ReadStream
      Set an exception handler on the read stream.
      Specified by:
      exceptionHandler in interface ReadStream<io.vertx.core.buffer.Buffer>
      Specified by:
      exceptionHandler in interface StreamBase
      Parameters:
      handler - the exception handler. Can be null.
      Returns:
      a reference to this, so the API can be used fluently
    • handler

      public HttpClientResponse handler(Consumer<io.vertx.core.buffer.Buffer> handler)
      Description copied from interface: ReadStream
      Set a data handler. As data is read, the handler will be called with the data.
      Specified by:
      handler in interface ReadStream<io.vertx.core.buffer.Buffer>
      Returns:
      a reference to this, so the API can be used fluently
    • pause

      public HttpClientResponse pause()
      Description copied from interface: ReadStream
      Pause the ReadStream, it sets the buffer in fetch mode and clears the actual demand.

      While it's paused, no data will be sent to the data handler.

      Specified by:
      pause in interface ReadStream<io.vertx.core.buffer.Buffer>
      Returns:
      a reference to this, so the API can be used fluently
    • endHandler

      public HttpClientResponse endHandler(Runnable endHandler)
      Description copied from interface: ReadStream
      Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.
      Specified by:
      endHandler in interface ReadStream<io.vertx.core.buffer.Buffer>
      Returns:
      a reference to this, so the API can be used fluently
    • netSocket

      public NetSocket netSocket()
      Returns:
      a NetSocket facade to interact with the HTTP client response.
    • getTrailer

      public String getTrailer(String trailerName)
      Return the first trailer value with the specified name
      Parameters:
      trailerName - the trailer name
      Returns:
      the trailer value. Can be null.
    • trailers

      public io.vertx.core.MultiMap trailers()
      Returns:
      the trailers
    • bodyHandler

      public HttpClientResponse bodyHandler(Consumer<io.vertx.core.buffer.Buffer> bodyHandler)
      Convenience method for receiving the entire request body in one piece.

      This saves you having to manually set a dataHandler and an endHandler and append the chunks of the body until the whole body received. Don't use this if your request body is large - you could potentially run out of RAM.

      Parameters:
      bodyHandler - This handler will be called after all the body has been received
    • customFrameHandler

      public HttpClientResponse customFrameHandler(Consumer<io.vertx.core.http.HttpFrame> handler)
      Set an custom frame handler. The handler will get notified when the http stream receives an custom HTTP/2 frame. HTTP/2 permits extension of the protocol.
      Returns:
      a reference to this, so the API can be used fluently
    • request

      public HttpClientRequest request()
      Returns:
      the corresponding request
    • streamPriorityHandler

      public HttpClientResponse streamPriorityHandler(Consumer<io.vertx.core.http.StreamPriority> handler)
      Set an handler for stream priority changes.

      This is not implemented for HTTP/1.x.

      Parameters:
      handler - the handler to be called when the stream priority changes
    • getHeader

      public String getHeader(CharSequence arg0)
      Return the first header value with the specified name
      Specified by:
      getHeader in interface HttpResponseHead
      Parameters:
      headerName - the header name
      Returns:
      the header value. Can be null.
    • statusMessage

      public String statusMessage()
      Specified by:
      statusMessage in interface HttpResponseHead
      Returns:
      the status message of the response
    • version

      public io.vertx.core.http.HttpVersion version()
      Specified by:
      version in interface HttpResponseHead
      Returns:
      the version of the response
    • statusCode

      public int statusCode()
      Specified by:
      statusCode in interface HttpResponseHead
      Returns:
      the status code of the response
    • pipe

      public Pipe<io.vertx.core.buffer.Buffer> pipe()
      Pause this stream and return a Pipe to transfer the elements of this stream to a destination WriteStream.

      The stream will be resumed when the pipe will be wired to a WriteStream.

      Specified by:
      pipe in interface ReadStream<io.vertx.core.buffer.Buffer>
      Returns:
      a pipe
    • headers

      public io.vertx.core.MultiMap headers()
      Specified by:
      headers in interface HttpResponseHead
      Returns:
      the headers
    • cookies

      public List<String> cookies()
      Specified by:
      cookies in interface HttpResponseHead
      Returns:
      the Set-Cookie headers (including trailers)
    • getHeader

      public String getHeader(String arg0)
      Return the first header value with the specified name
      Specified by:
      getHeader in interface HttpResponseHead
      Parameters:
      headerName - the header name
      Returns:
      the header value. Can be null.
    • newInstance

      public static HttpClientResponse newInstance(io.vertx.core.http.HttpClientResponse delegate)
      Creates a new instance of the HttpClientResponse.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toMulti

      @CheckReturnValue public io.smallrye.mutiny.Multi<io.vertx.core.buffer.Buffer> toMulti()
    • toBlockingIterable

      public Iterable<io.vertx.core.buffer.Buffer> toBlockingIterable()
    • toBlockingStream

      public Stream<io.vertx.core.buffer.Buffer> toBlockingStream()