public class HttpHandlerConnector extends Object implements ClientHttpConnector
HttpHandler
rather
than making actual requests to a network socket.
Internally the connector uses and adapts
MockClientHttpRequest
and MockClientHttpResponse
to
MockServerHttpRequest
and MockServerHttpResponse
.
Modifier and Type | Class and Description |
---|---|
static class |
HttpHandlerConnector.FailureAfterResponseCompletedException
Indicates that an error occurred after the server response was completed,
via
ReactiveHttpOutputMessage.writeWith(org.reactivestreams.Publisher<? extends org.springframework.core.io.buffer.DataBuffer>) or ReactiveHttpOutputMessage.setComplete() ,
and can no longer be changed. |
Constructor and Description |
---|
HttpHandlerConnector(HttpHandler handler)
Constructor with the
HttpHandler to handle requests with. |
Modifier and Type | Method and Description |
---|---|
reactor.core.publisher.Mono<ClientHttpResponse> |
connect(HttpMethod httpMethod,
URI uri,
Function<? super ClientHttpRequest,reactor.core.publisher.Mono<Void>> requestCallback)
Connect to the origin server using the given
HttpMethod and
URI and apply the given requestCallback when the HTTP
request of the underlying API can be initialized and written to. |
public HttpHandlerConnector(HttpHandler handler)
HttpHandler
to handle requests with.public reactor.core.publisher.Mono<ClientHttpResponse> connect(HttpMethod httpMethod, URI uri, Function<? super ClientHttpRequest,reactor.core.publisher.Mono<Void>> requestCallback)
ClientHttpConnector
HttpMethod
and
URI
and apply the given requestCallback
when the HTTP
request of the underlying API can be initialized and written to.connect
in interface ClientHttpConnector
httpMethod
- the HTTP request methoduri
- the HTTP request URIrequestCallback
- a function that prepares and writes to the request,
returning a publisher that signals when it's done writing.
Implementations can return a Mono<Void>
by calling
ReactiveHttpOutputMessage.writeWith(org.reactivestreams.Publisher<? extends org.springframework.core.io.buffer.DataBuffer>)
or ReactiveHttpOutputMessage.setComplete()
.ClientHttpResponse