Package org.springframework.http.client.reactive

# Class AbstractClientHttpRequest

java.lang.Object
org.springframework.http.client.reactive.AbstractClientHttpRequest

All Implemented Interfaces:
  `ClientHttpRequest`, `HttpMessage`, `ReactiveHttpOutputMessage`

public abstract class AbstractClientHttpRequest extends Object implements ClientHttpRequest
Base class for `ClientHttpRequest` implementations.

Since:
  5.0
Author:
  Rossen Stoyanchev, Brian Clozel

## Constructor Summary

Constructors
Constructor
Description
`AbstractClientHttpRequest()`
`AbstractClientHttpRequest(HttpHeaders headers)`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`applyAttributes()`
Add attributes from `getAttributes()` to the underlying request.
`protected abstract void`
`applyCookies()`
Add cookies from `getHeaders()` to the underlying request.
`protected abstract void`
`applyHeaders()`
Apply header changes from `getHeaders()` to the underlying request.
`void`
`beforeCommit(Supplier<? extends reactor.core.publisher.Mono<Void>> action)`
Register an action to apply just before the HttpOutputMessage is committed.
`protected reactor.core.publisher.Mono<Void>`
`doCommit()`
A variant of `doCommit(Supplier)` for a request without body.
`protected reactor.core.publisher.Mono<Void>`
`doCommit(Supplier<? extends Publisher<Void>> writeAction)`
Apply `beforeCommit` actions, apply the request headers/cookies, and write the request body.
`Map<String,Object>`
`getAttributes()`
Return a mutable map of the request attributes.
`org.springframework.util.MultiValueMap<String,HttpCookie>`
`getCookies()`
Return a mutable map of request cookies to send to the server.
`HttpHeaders`
`getHeaders()`
Return the headers of this message.
`protected HttpHeaders`
`initReadOnlyHeaders()`
Initialize the read-only headers after the request is committed.
`boolean`
`isCommitted()`
Whether the HttpOutputMessage is committed.

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

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

### Methods inherited from interface org.springframework.http.client.reactive.ClientHttpRequest

`getMethod, getNativeRequest, getURI`

### Methods inherited from interface org.springframework.http.ReactiveHttpOutputMessage

`bufferFactory, setComplete, writeAndFlushWith, writeWith`

## Constructor Details

### AbstractClientHttpRequest

public AbstractClientHttpRequest()

### AbstractClientHttpRequest

public AbstractClientHttpRequest(HttpHeaders headers)

## Method Details

### 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`)

### initReadOnlyHeaders

protected HttpHeaders initReadOnlyHeaders()
Initialize the read-only headers after the request is committed.

By default, this method simply applies a read-only wrapper. Subclasses can do the same for headers from the native request.

Since:
  5.3.15

### getCookies

public org.springframework.util.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`

### getAttributes

public Map<String,Object> getAttributes()
Description copied from interface: `ClientHttpRequest`
Return a mutable map of the request attributes.

Specified by:
  `getAttributes` in interface `ClientHttpRequest`

### 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, for example, 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`

### doCommit

protected reactor.core.publisher.Mono<Void> doCommit()
A variant of `doCommit(Supplier)` for a request without body.

Returns:
  a completion publisher

### doCommit

protected reactor.core.publisher.Mono<Void> doCommit(@Nullable Supplier<? extends Publisher<Void>> writeAction)
Apply `beforeCommit` actions, apply the request headers/cookies, and write the request body.

Parameters:
  `writeAction` - the action to write the request body (may be `null`)
Returns:
  a completion publisher

### applyHeaders

protected abstract void applyHeaders()
Apply header changes from `getHeaders()` to the underlying request. This method is called once only.

### applyCookies

protected abstract void applyCookies()
Add cookies from `getHeaders()` to the underlying request. This method is called once only.

### applyAttributes

protected void applyAttributes()
Add attributes from `getAttributes()` to the underlying request. This method is called once only.

Since:
  6.2