Class ClientHttpRequestDecorator
java.lang.Object
org.springframework.http.client.reactive.ClientHttpRequestDecorator
- All Implemented Interfaces:
ClientHttpRequest
,HttpMessage
,ReactiveHttpOutputMessage
Wraps another
ClientHttpRequest
and delegates all methods to it.
Subclasses can override specific methods selectively.- Since:
- 5.0
- Author:
- Rossen Stoyanchev
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
beforeCommit
(Supplier<? extends reactor.core.publisher.Mono<Void>> action) Register an action to apply just before the HttpOutputMessage is committed.Return aDataBufferFactory
that can be used to create the body.Return a mutable map of request cookies to send to the server.Return the headers of this message.Return the HTTP method of the request.<T> T
Return the request from the underlying HTTP library.getURI()
Return the URI of the request.boolean
Whether the HttpOutputMessage is committed.reactor.core.publisher.Mono<Void>
Indicate that message handling is complete, allowing for any cleanup or end-of-processing tasks to be performed such as applying header changes made viaHttpMessage.getHeaders()
to the underlying HTTP message (if not applied already).toString()
reactor.core.publisher.Mono<Void>
writeAndFlushWith
(Publisher<? extends Publisher<? extends DataBuffer>> body) Use the givenPublisher
ofPublishers
to write the body of the HttpOutputMessage to the underlying HTTP layer, flushing after eachPublisher<DataBuffer>
.reactor.core.publisher.Mono<Void>
writeWith
(Publisher<? extends DataBuffer> body) Use the givenPublisher
to write the body of the message to the underlying HTTP layer.
-
Constructor Details
-
ClientHttpRequestDecorator
-
-
Method Details
-
getDelegate
-
getMethod
Description copied from interface:ClientHttpRequest
Return the HTTP method of the request.- Specified by:
getMethod
in interfaceClientHttpRequest
-
getURI
Description copied from interface:ClientHttpRequest
Return the URI of the request.- Specified by:
getURI
in interfaceClientHttpRequest
-
getHeaders
Description copied from interface:HttpMessage
Return the headers of this message.- Specified by:
getHeaders
in interfaceHttpMessage
- Returns:
- a corresponding HttpHeaders object (never
null
)
-
getCookies
Description copied from interface:ClientHttpRequest
Return a mutable map of request cookies to send to the server.- Specified by:
getCookies
in interfaceClientHttpRequest
-
bufferFactory
Description copied from interface:ReactiveHttpOutputMessage
Return aDataBufferFactory
that can be used to create the body.- Specified by:
bufferFactory
in interfaceReactiveHttpOutputMessage
- Returns:
- a buffer factory
- See Also:
-
getNativeRequest
public <T> T getNativeRequest()Description copied from interface:ClientHttpRequest
Return the request from the underlying HTTP library.- Specified by:
getNativeRequest
in interfaceClientHttpRequest
- Type Parameters:
T
- the expected type of the request to cast to
-
beforeCommit
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>>)
orMono.fromRunnable(java.lang.Runnable)
, to ensure it's executed in the right order, relative to other actions.- Specified by:
beforeCommit
in interfaceReactiveHttpOutputMessage
- Parameters:
action
- the action to apply
-
isCommitted
public boolean isCommitted()Description copied from interface:ReactiveHttpOutputMessage
Whether the HttpOutputMessage is committed.- Specified by:
isCommitted
in interfaceReactiveHttpOutputMessage
-
writeWith
Description copied from interface:ReactiveHttpOutputMessage
Use the givenPublisher
to write the body of the message to the underlying HTTP layer.- Specified by:
writeWith
in interfaceReactiveHttpOutputMessage
- 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 givenPublisher
ofPublishers
to write the body of the HttpOutputMessage to the underlying HTTP layer, flushing after eachPublisher<DataBuffer>
.- Specified by:
writeAndFlushWith
in interfaceReactiveHttpOutputMessage
- Parameters:
body
- the body content publisher- Returns:
- a
Mono
that indicates completion or error
-
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 viaHttpMessage.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 interfaceReactiveHttpOutputMessage
- Returns:
- a
Mono
that indicates completion or error
-
toString
-