Interface InterceptedResponseBody

All Known Subinterfaces:
InterceptedWebResponseBody

public interface InterceptedResponseBody

An intercepted response body allows to transform the response payload received from the endpoint and/or provide a response payload in case the request sent is cancelled.

It is exposed in the InterceptedRequest, once the request has been sent to the endpoint and an actual response received it is no longer possible to provide a response payload and IllegalStateException shall be raised.

Since:
1.6
Author:
Jeremy Kuhn
See Also:
  • Method Details

    • transform

      Transforms the response payload publisher.

      This can be used in an exchange interceptor in order to decorate the response data publisher.

      Parameters:
      transformer - a payload publisher transformer
      Returns:
      the response body
      Throws:
      IllegalStateException - if the response payload publisher has already been subscribed
    • empty

      void empty()

      Produces an empty payload.

      If a payload has already been provided this method does nothing.

      A typical usage is:

      
       exchange.response().body().empty();
       
    • raw

      Returns a raw payload producer.

      A typical usage is:

      
       exchange.response().body().raw().stream(
           Flux.just(
               Unpooled.unreleasableBuffer(Unpooled.copiedBuffer("Hello ", Charsets.DEFAULT)), 
               Unpooled.unreleasableBuffer(Unpooled.copiedBuffer("World!", Charsets.DEFAULT))
           )
       );
       
      Returns:
      a raw payload producer
    • string

      <T extends CharSequence> OutboundData<T> string()

      Returns a string payload producer.

      A typical usage is:

      
       exchange.response().body().string().stream(
           Flux.just(
               Unpooled.unreleasableBuffer("Hello "), 
               Unpooled.unreleasableBuffer("World!")
           )
       );
       
      Type Parameters:
      T - the type of char sequence
      Returns:
      a string payload producer
    • resource

      Returns a resource payload producer.

      A typical usage is:

      
       ResourceService resourceService = ... 
       exchange.response().body().resource().value(resourceService.get("file:/path/to/resource");
       
      Returns:
      a resource payload producer