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 response. |
protected void |
applyHeaders()
Apply header changes from
AbstractClientHttpRequest.getHeaders() to the underlying response. |
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. |
HttpMethod |
getMethod()
Return the HTTP method of the request.
|
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(org.reactivestreams.Publisher<? extends org.reactivestreams.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(org.reactivestreams.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, isCommitted
public MockClientHttpRequest(HttpMethod httpMethod, String urlTemplate, Object... vars)
public MockClientHttpRequest(HttpMethod httpMethod, URI url)
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 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 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).protected void applyHeaders()
AbstractClientHttpRequest
AbstractClientHttpRequest.getHeaders()
to the underlying response.
This method is called once only.applyHeaders
in class AbstractClientHttpRequest
protected void applyCookies()
AbstractClientHttpRequest
AbstractClientHttpRequest.getHeaders()
to the underlying response.
This method is called once only.applyCookies
in class AbstractClientHttpRequest
public reactor.core.publisher.Mono<Void> writeWith(org.reactivestreams.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(org.reactivestreams.Publisher<? extends org.reactivestreams.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 error