Interface WebExchange<A extends ExchangeContext>

Type Parameters:
A - the exchange context type
All Superinterfaces:
BaseExchange<A,Request,Mono<? extends Response>>, Exchange<A>

public interface WebExchange<A extends ExchangeContext> extends Exchange<A>

An exchange that extends HTTP client Exchange with features for the Web.

It supports request body encoding based on the request content type as well as response body decoding based on the response content type.

It gives access to the request URI and exposes a context which used to propagate contextual information throughout the processing of the exchange.

Since:
1.12
Author:
Jeremy Kuhn
  • Method Details

    • failOnErrorStatus

      WebExchange<A> failOnErrorStatus(boolean failOnErrorStatus)

      Specifies whether an HttpException should be raised when a client or server error response is received.

      When set to true, the response() returns a Mono that fails when the response has a client (4xx) or server (5xx) error status code. This is the default behaviour.

      It is possible to customize how the response is mapped to the error in an exchange interceptor with InterceptedWebExchange.failOnErrorStatus(Function).

      Parameters:
      failOnErrorStatus - true to raise an HTTP exception on client (4xx) or server(5xx) error, false otherwise
      Returns:
      the Web exchange
    • request

      WebRequest request()
      Description copied from interface: BaseExchange

      Returns the request part of the exchange.

      Specified by:
      request in interface BaseExchange<A extends ExchangeContext,Request,Mono<? extends Response>>
      Returns:
      the request part
    • response

      Mono<WebResponse> response()
      Description copied from interface: Exchange

      Returns the response part of the exchange.

      The connection is created and the request sent when the returned publisher is subscribed.

      Specified by:
      response in interface BaseExchange<A extends ExchangeContext,Request,Mono<? extends Response>>
      Specified by:
      response in interface Exchange<A extends ExchangeContext>
      Returns:
      the response part
    • webSocket

      default Mono<Web2SocketExchange<A>> webSocket()
      Description copied from interface: Exchange

      Returns a WebSocket exchange publisher.

      The WebSocket connection and the corresponding WebSocketExchange are created when the returned publisher is subscribed.

      Specified by:
      webSocket in interface Exchange<A extends ExchangeContext>
      Returns:
      a WebSocket exchange mono
    • webSocket

      Mono<Web2SocketExchange<A>> webSocket(String subProtocol)
      Description copied from interface: Exchange

      Returns a WebSocket exchange publisher requesting the specified subprotocol.

      The WebSocket connection and the corresponding WebSocketExchange are created when the returned publisher is subscribed.

      Specified by:
      webSocket in interface Exchange<A extends ExchangeContext>
      Parameters:
      subProtocol - the subprotocol requested to the server by the client.
      Returns:
      a WebSocket exchange mono