org.springframework.http.client.reactive

## Class ClientHttpRequestDecorator

- java.lang.Object
- - org.springframework.http.client.reactive.ClientHttpRequestDecorator

- All Implemented Interfaces:
    ClientHttpRequest, HttpMessage, ReactiveHttpOutputMessage

      public class ClientHttpRequestDecorator
      extends Object
      implements ClientHttpRequest

  Wraps another `ClientHttpRequest` and delegates all methods to it. Subclasses can override specific methods selectively.
  Since:
    5.0
  Author:
    Rossen Stoyanchev

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClientHttpRequestDecorator(ClientHttpRequest delegate)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `beforeCommit(Supplier<? extends reactor.core.publisher.Mono<Void>> action)` Register an action to apply just before the HttpOutputMessage is committed.
    `DataBufferFactory` | `bufferFactory()` Return a `DataBufferFactory` that can be used to create the body.
    `MultiValueMap<String,HttpCookie>` | `getCookies()` Return a mutable map of request cookies to send to the server.
    `ClientHttpRequest` | `getDelegate()`
    `HttpHeaders` | `getHeaders()` Return the headers of this message.
    `HttpMethod` | `getMethod()` Return the HTTP method of the request.
    `<T> T` | `getNativeRequest()` Return the request from the underlying HTTP library.
    `URI` | `getURI()` Return the URI of the request.
    `boolean` | `isCommitted()` Whether the HttpOutputMessage is committed.
    `reactor.core.publisher.Mono<Void>` | `setComplete()` Indicate that message handling is complete, allowing for any cleanup or end-of-processing tasks to be performed such as applying header changes made via `HttpMessage.getHeaders()` to the underlying HTTP message (if not applied already).
    `String` | `toString()`
    `reactor.core.publisher.Mono<Void>` | `writeAndFlushWith(Publisher<? extends Publisher<? extends DataBuffer>> body)` Use the given `Publisher` of `Publishers` to write the body of the HttpOutputMessage to the underlying HTTP layer, flushing after each `Publisher<DataBuffer>`.
    `reactor.core.publisher.Mono<Void>` | `writeWith(Publisher<? extends DataBuffer> body)` Use the given `Publisher` to write the body of the message to the underlying HTTP layer.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ClientHttpRequestDecorator

          public ClientHttpRequestDecorator(ClientHttpRequest delegate)

  - ### Method Detail

    - #### getDelegate

          public ClientHttpRequest getDelegate()

    - #### getMethod

          public HttpMethod getMethod()

      Description copied from interface: `ClientHttpRequest`
      Return the HTTP method of the request.
      Specified by:
        `getMethod` in interface `ClientHttpRequest`

    - #### getURI

          public URI getURI()

      Description copied from interface: `ClientHttpRequest`
      Return the URI of the request.
      Specified by:
        `getURI` in interface `ClientHttpRequest`

    - #### getHeaders

          public HttpHeaders getHeaders()

      Description copied from interface: `HttpMessage`
      Return the headers of this message.
      Specified by:
        `getHeaders` in interface `HttpMessage`
      Returns:
        a corresponding HttpHeaders object (never `null`)

    - #### getCookies

          public MultiValueMap<String,HttpCookie> getCookies()

      Description copied from interface: `ClientHttpRequest`
      Return a mutable map of request cookies to send to the server.
      Specified by:
        `getCookies` in interface `ClientHttpRequest`

    - #### bufferFactory

          public DataBufferFactory bufferFactory()

      Description copied from interface: `ReactiveHttpOutputMessage`
      Return a `DataBufferFactory` that can be used to create the body.
      Specified by:
        `bufferFactory` in interface `ReactiveHttpOutputMessage`
      Returns:
        a buffer factory
      See Also:
        `ReactiveHttpOutputMessage.writeWith(Publisher)`

    - #### getNativeRequest

          public <T> T getNativeRequest()

      Description copied from interface: `ClientHttpRequest`
      Return the request from the underlying HTTP library.
      Specified by:
        `getNativeRequest` in interface `ClientHttpRequest`
      Type Parameters:
        `T` - the expected type of the request to cast to

    - #### beforeCommit

          public void beforeCommit(Supplier<? extends reactor.core.publisher.Mono<Void>> action)

      Description copied from interface: `ReactiveHttpOutputMessage`
      Register an action to apply just before the HttpOutputMessage is committed.

      Note: the supplied action must be properly deferred, e.g. via `Mono.defer(java.util.function.Supplier<? extends reactor.core.publisher.Mono<? extends T>>)` or `Mono.fromRunnable(java.lang.Runnable)`, to ensure it's executed in the right order, relative to other actions.

      Specified by:
        `beforeCommit` in interface `ReactiveHttpOutputMessage`
      Parameters:
        `action` - the action to apply

    - #### isCommitted

          public boolean isCommitted()

      Description copied from interface: `ReactiveHttpOutputMessage`
      Whether the HttpOutputMessage is committed.
      Specified by:
        `isCommitted` in interface `ReactiveHttpOutputMessage`

    - #### writeWith

          public reactor.core.publisher.Mono<Void> writeWith(Publisher<? extends DataBuffer> body)

      Description copied from interface: `ReactiveHttpOutputMessage`
      Use the given `Publisher` to write the body of the message to the underlying HTTP layer.
      Specified by:
        `writeWith` in interface `ReactiveHttpOutputMessage`
      Parameters:
        `body` - the body content publisher
      Returns:
        a `Mono` that indicates completion or error

    - #### writeAndFlushWith

          public reactor.core.publisher.Mono<Void> writeAndFlushWith(Publisher<? extends Publisher<? extends DataBuffer>> body)

      Description copied from interface: `ReactiveHttpOutputMessage`
      Use the given `Publisher` of `Publishers` to write the body of the HttpOutputMessage to the underlying HTTP layer, flushing after each `Publisher<DataBuffer>`.
      Specified by:
        `writeAndFlushWith` in interface `ReactiveHttpOutputMessage`
      Parameters:
        `body` - the body content publisher
      Returns:
        a `Mono` that indicates completion or error

    - #### setComplete

          public reactor.core.publisher.Mono<Void> setComplete()

      Description copied from interface: `ReactiveHttpOutputMessage`
      Indicate that message handling is complete, allowing for any cleanup or end-of-processing tasks to be performed such as applying header changes made via `HttpMessage.getHeaders()` to the underlying HTTP message (if not applied already).

      This method should be automatically invoked at the end of message processing so typically applications should not have to invoke it. If invoked multiple times it should have no side effects.

      Specified by:
        `setComplete` in interface `ReactiveHttpOutputMessage`
      Returns:
        a `Mono` that indicates completion or error

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`