Interface Response


  • public interface Response
    • Method Detail

      • status

        Response status​(int statusCode)
      • status

        int status()
      • reason

        String reason()
        Returns:
        Reason-Phrase is intended to give a short textual description of the Status-Code.
      • headers

        HttpHeaders headers()
        Returns:
        the headers in the response.
      • ended

        boolean ended()
        Indicates if the response is ended or not. Ended response means the response has been fully push to the client, including response body.
        Returns:
        true if the response has been fully pushed to the client, false else.
      • body

        io.reactivex.Maybe<Buffer> body()
        Get the current body response as a Maybe. If no body has not been set on the response yet, an empty Maybe will returned. By getting the body as a Maybe, the current body chunks will be merged together to reconstruct the entire body in provide it in the form of a single Buffer This is useful when the entire body is required to apply some transformation or any manipulation. WARN: beware that the entire body content will be loaded in memory. You should not keep a direct reference on the body chunks as they could be overridden by others at anytime.
        Returns:
        a Maybe observable containing the current entire body response or empty if response body as not been set yet.
        See Also:
        bodyOrEmpty()
      • bodyOrEmpty

        io.reactivex.Single<Buffer> bodyOrEmpty()
        Same as body() but returns a Single of Buffer instead. If no body response as been set yet, it returns a Single with an empty Buffer. It is a convenient way that avoid checking if the body is set or not prior to manipulate it.
        Returns:
        a Single observable containing the current entire body response or empty an {@link Buffer) if response body as not been set yet.
        See Also:
        body()
      • body

        void body​(Buffer buffer)
        Set the current body response as a Buffer. This is useful when you want to replace the current body response with a specific content that doesn't come from a reactive chain, ex: response.body(Buffer.buffer("My custom content"); WARN: replacing the request body will "drain" the previous request that was in place but occurs outside the reactive chain. You should consider using onBody(MaybeTransformer) to change the body during the chain execution.
        See Also:
        onBody(MaybeTransformer), chunks(Flowable)
      • onBody

        io.reactivex.Completable onBody​(io.reactivex.MaybeTransformer<Buffer,​Buffer> onBody)
        Applies a transformation on the complete body given as a single Buffer. Ex: response.onBody(body -> body.map(buffer ->Buffer.buffer(buffer.toString().toUpperCase()))); IMPORTANT: applying a transformation on the body content loads the whole body in memory. It's up to the consumer to make sure it is safe to do that without consuming too much memory.
        Parameters:
        onBody - the transformation that will be applied on the body.
        Returns:
        a Completable that completes once the body transformation has occurred.
      • chunks

        void chunks​(io.reactivex.Flowable<Buffer> chunks)
        Set the current response body chunks from a Flowable of Buffer. This is useful to directly pump the upstream chunks to the downstream without having to load all the chunks in memory.
        WARN: replacing the response body will "drain" the previous response that was in place.
        Parameters:
        chunks - the flowable of chunks representing the response to push back to the downstream.
        See Also:
        body()
      • chunks

        io.reactivex.Flowable<Buffer> chunks()
        Get the current response body chunks as Flowable of Buffer. This is useful when you want to manipulate the entire body without having to load it in memory. WARN: you should not keep a direct reference on the body chunks as they could be overridden by others at anytime.
        Returns:
        a Flowable containing the current body response chunks.
      • onChunk

        io.reactivex.Completable onChunk​(io.reactivex.FlowableTransformer<Buffer,​Buffer> onChunk)
        Applies a transformation on each body chunks and completes when all the chunks have been processed. Ex: response.onChunk(chunks -> chunks.map(buffer -> Buffer.buffer(buffer.toString().toUpperCase()))); IMPORTANT: applying a transformation on the body chunks loads the whole body in memory. It's up to the consumer to make sure it is safe to do that without consuming too much memory. IMPORTANT: applying a transformation on chunks completes when all chunks have been transformed. If used in a policy chain, it means that the next policy will start once all chunks have been transformed
        Parameters:
        onChunk - the transformer that will be applied.
        Returns:
        a Completable that completes once the body transformation has occurred on all the chunks.
      • end

        io.reactivex.Completable end()
        End the response.
        Returns:
        an observable that can be easily chained.