Top Description Inners Fields Constructors Methods
org.springframework.http.client.reactive

public abstract Class AbstractClientHttpRequest

extends Object
implements ClientHttpRequest
Class Inheritance
All Implemented Interfaces
org.springframework.http.client.reactive.ClientHttpRequest, org.springframework.http.ReactiveHttpOutputMessage, org.springframework.http.HttpMessage
Known Direct Subclasses
org.springframework.http.client.reactive.HttpComponentsClientHttpRequest, org.springframework.http.client.reactive.JdkClientHttpRequest, org.springframework.http.client.reactive.JettyClientHttpRequest, org.springframework.http.client.reactive.ReactorClientHttpRequest, org.springframework.http.client.reactive.ReactorNetty2ClientHttpRequest
Imports
java.util.ArrayList, .List, java.util.concurrent.atomic.AtomicReference, java.util.function.Supplier, org.reactivestreams.Publisher, reactor.core.publisher.Flux, .Mono, org.springframework.http.HttpCookie, .HttpHeaders, org.springframework.lang.Nullable, org.springframework.util.Assert, .CollectionUtils, .LinkedMultiValueMap, .MultiValueMap

Base class for ClientHttpRequest implementations.
Authors
Rossen Stoyanchev, Brian Clozel
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
AbstractClientHttpRequest.State

COMMITTING -> COMMITTED is the period after doCommit is called but before the response status and headers have been applied to the underlying response during which time pre-commit actions can still make changes to the response status and headers.

Field Summary

Modifier and TypeField and Description
private final List<Supplier<? extends Publisher<Void>>>
private final MultiValueMap<String, HttpCookie>
private final HttpHeaders
private HttpHeaders
private final AtomicReference<AbstractClientHttpRequest.State>

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
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.

public void
beforeCommit(Supplier<? extends Mono<Void>>
the action to apply
action
)

Implements org.springframework.http.ReactiveHttpOutputMessage.beforeCommit.

Register an action to apply just before the HttpOutputMessage is committed.
protected Mono<Void>

Returns:

a completion publisher
doCommit
()

A variant of doCommit(Supplier) for a request without body.

protected Mono<Void>

Returns:

a completion publisher
doCommit
(Supplier<? extends Publisher<Void>>
the action to write the request body (may be null)
writeAction
)

Apply beforeCommit actions, apply the request headers/cookies, and write the request body.

public MultiValueMap<String, HttpCookie>
getCookies()

Implements org.springframework.http.client.reactive.ClientHttpRequest.getCookies.

Return a mutable map of request cookies to send to the server.
public HttpHeaders
getHeaders()

Implements org.springframework.http.HttpMessage.getHeaders.

Return the headers of this message.
protected HttpHeaders
initReadOnlyHeaders()

Initialize the read-only headers after the request is committed.

public boolean
isCommitted()

Implements org.springframework.http.ReactiveHttpOutputMessage.isCommitted.

Whether the HttpOutputMessage is committed.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

commitActionsback to summary
private final List<Supplier<? extends Publisher<Void>>> commitActions
cookiesback to summary
private final MultiValueMap<String, HttpCookie> cookies
headersback to summary
private final HttpHeaders headers
readOnlyHeadersback to summary
private HttpHeaders readOnlyHeaders
Annotations
@Nullable
stateback to summary
private final AtomicReference<AbstractClientHttpRequest.State> state

Constructor Detail

AbstractClientHttpRequestback to summary
public AbstractClientHttpRequest()
AbstractClientHttpRequestback to summary
public AbstractClientHttpRequest(HttpHeaders headers)

Method Detail

applyCookiesback to summary
protected abstract void applyCookies()

Add cookies from getHeaders() to the underlying request. This method is called once only.

applyHeadersback to summary
protected abstract void applyHeaders()

Apply header changes from getHeaders() to the underlying request. This method is called once only.

beforeCommitback to summary
public void beforeCommit(Supplier<? extends Mono<Void>> action)

Implements org.springframework.http.ReactiveHttpOutputMessage.beforeCommit.

Doc from org.springframework.http.ReactiveHttpOutputMessage.beforeCommit.

Register an action to apply just before the HttpOutputMessage is committed.

Note

the supplied action must be properly deferred, e.g. via Mono#defer or Mono#fromRunnable, to ensure it's executed in the right order, relative to other actions.

Parameters
action:Supplier<? extends Mono<Void>>

the action to apply

Annotations
@Override
doCommitback to summary
protected Mono<Void> doCommit()

A variant of doCommit(Supplier) for a request without body.

Returns:Mono<Void>

a completion publisher

doCommitback to summary
protected Mono<Void> doCommit(Supplier<? extends Publisher<Void>> writeAction)

Apply beforeCommit actions, apply the request headers/cookies, and write the request body.

Parameters
writeAction:Supplier<? extends Publisher<Void>>

the action to write the request body (may be null)

Returns:Mono<Void>

a completion publisher

getCookiesback to summary
public MultiValueMap<String, HttpCookie> getCookies()

Implements org.springframework.http.client.reactive.ClientHttpRequest.getCookies.

Doc from org.springframework.http.client.reactive.ClientHttpRequest.getCookies.

Return a mutable map of request cookies to send to the server.

Annotations
@Override
getHeadersback to summary
public HttpHeaders getHeaders()

Implements org.springframework.http.HttpMessage.getHeaders.

Doc from org.springframework.http.HttpMessage.getHeaders.

Return the headers of this message.

Returns:HttpHeaders

a corresponding HttpHeaders object (never null)

Annotations
@Override
initReadOnlyHeadersback to summary
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
isCommittedback to summary
public boolean isCommitted()

Implements org.springframework.http.ReactiveHttpOutputMessage.isCommitted.

Doc from org.springframework.http.ReactiveHttpOutputMessage.isCommitted.

Whether the HttpOutputMessage is committed.

Annotations
@Override
org.springframework.http.client.reactive back to summary

private final Enum AbstractClientHttpRequest.State

extends Enum<AbstractClientHttpRequest.State>
Class Inheritance

COMMITTING -> COMMITTED is the period after doCommit is called but before the response status and headers have been applied to the underlying response during which time pre-commit actions can still make changes to the response status and headers.

Field Summary

Modifier and TypeField and Description
public static final AbstractClientHttpRequest.State
public static final AbstractClientHttpRequest.State
public static final AbstractClientHttpRequest.State

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static AbstractClientHttpRequest.State
public static AbstractClientHttpRequest.State[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

COMMITTEDback to summary
public static final AbstractClientHttpRequest.State COMMITTED
COMMITTINGback to summary
public static final AbstractClientHttpRequest.State COMMITTING
NEWback to summary
public static final AbstractClientHttpRequest.State NEW

Constructor Detail

Stateback to summary
private State()

Method Detail

valueOfback to summary
public static AbstractClientHttpRequest.State valueOf(String name)
valuesback to summary
public static AbstractClientHttpRequest.State[] values()