Class AbstractClientHttpRequest
- java.lang.Object
- org.springframework.http.client.reactive.AbstractClientHttpRequest
- All Implemented Interfaces:
ClientHttpRequest,HttpMessage,ReactiveHttpOutputMessage
- Direct Known Subclasses:
MockClientHttpRequest
public abstract class AbstractClientHttpRequest extends Object implements ClientHttpRequest
Base class forClientHttpRequestimplementations.- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Brian Clozel
Constructor Summary
Constructors Constructor Description AbstractClientHttpRequest()AbstractClientHttpRequest(HttpHeaders headers)
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidapplyCookies()Add cookies fromgetHeaders()to the underlying request.protected abstract voidapplyHeaders()Apply header changes fromgetHeaders()to the underlying request.voidbeforeCommit(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 ofdoCommit(Supplier)for a request without body.protected reactor.core.publisher.Mono<Void>doCommit(Supplier<? extends org.reactivestreams.Publisher<Void>> writeAction)ApplybeforeCommitactions, apply the request headers/cookies, and write the request body.MultiValueMap<String,HttpCookie>getCookies()Return a mutable map of request cookies to send to the server.HttpHeadersgetHeaders()Return the headers of this message.booleanisCommitted()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, getURI
Methods inherited from interface org.springframework.http.ReactiveHttpOutputMessage
bufferFactory, setComplete, writeAndFlushWith, writeWith
Constructor Detail
AbstractClientHttpRequest
public AbstractClientHttpRequest()
AbstractClientHttpRequest
public AbstractClientHttpRequest(HttpHeaders headers)
Method Detail
getHeaders
public HttpHeaders getHeaders()
Description copied from interface:HttpMessageReturn the headers of this message.- Specified by:
getHeadersin interfaceHttpMessage- Returns:
- a corresponding HttpHeaders object (never
null)
getCookies
public MultiValueMap<String,HttpCookie> getCookies()
Description copied from interface:ClientHttpRequestReturn a mutable map of request cookies to send to the server.- Specified by:
getCookiesin interfaceClientHttpRequest
beforeCommit
public void beforeCommit(Supplier<? extends reactor.core.publisher.Mono<Void>> action)
Description copied from interface:ReactiveHttpOutputMessageRegister 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>>)orMono.fromRunnable(java.lang.Runnable), to ensure it's executed in the right order, relative to other actions.- Specified by:
beforeCommitin interfaceReactiveHttpOutputMessage- Parameters:
action- the action to apply
isCommitted
public boolean isCommitted()
Description copied from interface:ReactiveHttpOutputMessageWhether the HttpOutputMessage is committed.- Specified by:
isCommittedin interfaceReactiveHttpOutputMessage
doCommit
protected reactor.core.publisher.Mono<Void> doCommit()
A variant ofdoCommit(Supplier)for a request without body.- Returns:
- a completion publisher
doCommit
protected reactor.core.publisher.Mono<Void> doCommit(@Nullable Supplier<? extends org.reactivestreams.Publisher<Void>> writeAction)
ApplybeforeCommitactions, apply the request headers/cookies, and write the request body.- Parameters:
writeAction- the action to write the request body (may benull)- Returns:
- a completion publisher
applyHeaders
protected abstract void applyHeaders()
Apply header changes fromgetHeaders()to the underlying request. This method is called once only.
applyCookies
protected abstract void applyCookies()
Add cookies fromgetHeaders()to the underlying request. This method is called once only.