public class MockClientHttpRequest extends AbstractClientHttpRequest
ClientHttpRequest
.Constructor and Description |
---|
MockClientHttpRequest(HttpMethod httpMethod,
String urlTemplate,
Object... vars) |
MockClientHttpRequest(HttpMethod httpMethod,
URI url) |
Modifier and Type | Method and Description |
---|---|
protected void |
applyCookies()
Add cookies from
AbstractClientHttpRequest.getHeaders() to the underlying request. |
protected void |
applyHeaders()
Apply header changes from
AbstractClientHttpRequest.getHeaders() to the underlying request. |
DataBufferFactory |
bufferFactory()
Return a
DataBufferFactory that can be used to create the body. |
reactor.core.publisher.Flux<DataBuffer> |
getBody()
Return the request body, or an error stream if the body was never set
or when
setWriteHandler(java.util.function.Function<reactor.core.publisher.Flux<org.springframework.core.io.buffer.DataBuffer>, reactor.core.publisher.Mono<java.lang.Void>>) is configured. |
reactor.core.publisher.Mono<String> |
getBodyAsString()
Aggregate response data and convert to a String using the "Content-Type"
charset or "UTF-8" by default.
|
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.
|
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). |
void |
setWriteHandler(Function<reactor.core.publisher.Flux<DataBuffer>,reactor.core.publisher.Mono<Void>> writeHandler)
Configure a custom handler for writing the request body.
|
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. |
beforeCommit, doCommit, doCommit, getCookies, getHeaders, initReadOnlyHeaders, isCommitted
public MockClientHttpRequest(HttpMethod httpMethod, String urlTemplate, Object... vars)
public MockClientHttpRequest(HttpMethod httpMethod, URI url)
public void setWriteHandler(Function<reactor.core.publisher.Flux<DataBuffer>,reactor.core.publisher.Mono<Void>> writeHandler)
The default write handler consumes and caches the request body so it may be accessed subsequently, e.g. in test assertions. Use this property when the request body is an infinite stream.
writeHandler
- the write handler to use returning Mono<Void>
when the body has been "written" (i.e. consumed).public HttpMethod getMethod()
ClientHttpRequest
public URI getURI()
ClientHttpRequest
public DataBufferFactory bufferFactory()
ReactiveHttpOutputMessage
DataBufferFactory
that can be used to create the body.ReactiveHttpOutputMessage.writeWith(Publisher)
public <T> T getNativeRequest()
ClientHttpRequest
T
- the expected type of the request to cast toprotected void applyHeaders()
AbstractClientHttpRequest
AbstractClientHttpRequest.getHeaders()
to the underlying request.
This method is called once only.applyHeaders
in class AbstractClientHttpRequest
protected void applyCookies()
AbstractClientHttpRequest
AbstractClientHttpRequest.getHeaders()
to the underlying request.
This method is called once only.applyCookies
in class AbstractClientHttpRequest
public reactor.core.publisher.Mono<Void> writeWith(Publisher<? extends DataBuffer> body)
ReactiveHttpOutputMessage
Publisher
to write the body of the message to the
underlying HTTP layer.body
- the body content publisherMono
that indicates completion or errorpublic reactor.core.publisher.Mono<Void> writeAndFlushWith(Publisher<? extends Publisher<? extends DataBuffer>> body)
ReactiveHttpOutputMessage
Publisher
of Publishers
to write the body
of the HttpOutputMessage to the underlying HTTP layer, flushing after
each Publisher<DataBuffer>
.body
- the body content publisherMono
that indicates completion or errorpublic reactor.core.publisher.Mono<Void> setComplete()
ReactiveHttpOutputMessage
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.
Mono
that indicates completion or errorpublic reactor.core.publisher.Flux<DataBuffer> getBody()
setWriteHandler(java.util.function.Function<reactor.core.publisher.Flux<org.springframework.core.io.buffer.DataBuffer>, reactor.core.publisher.Mono<java.lang.Void>>)
is configured.public reactor.core.publisher.Mono<String> getBodyAsString()