Class HttpHandlerConnector
- java.lang.Object
- org.springframework.test.web.reactive.server.HttpHandlerConnector
- All Implemented Interfaces:
ClientHttpConnector
public class HttpHandlerConnector extends Object implements ClientHttpConnector
Connector that handles requests by invoking anHttpHandler
rather than making actual requests to a network socket.Internally the connector uses and adapts
MockClientHttpRequest
andMockClientHttpResponse
toMockServerHttpRequest
andMockServerHttpResponse
.- Since:
- 5.0
- Author:
- Rossen Stoyanchev
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HttpHandlerConnector.FailureAfterResponseCompletedException
Indicates that an error occurred after the server response was completed, viaReactiveHttpOutputMessage.writeWith(org.reactivestreams.Publisher<? extends org.springframework.core.io.buffer.DataBuffer>)
orReactiveHttpOutputMessage.setComplete()
, and can no longer be changed.
Constructor Summary
Constructors Constructor Description HttpHandlerConnector(HttpHandler handler)
Constructor with theHttpHandler
to handle requests with.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 givenHttpMethod
andURI
and apply the givenrequestCallback
when the HTTP request of the underlying API can be initialized and written to.
Constructor Detail
HttpHandlerConnector
public HttpHandlerConnector(HttpHandler handler)
Constructor with theHttpHandler
to handle requests with.
Method Detail
connect
public reactor.core.publisher.Mono<ClientHttpResponse> connect(HttpMethod httpMethod, URI uri, Function<? super ClientHttpRequest,reactor.core.publisher.Mono<Void>> requestCallback)
Description copied from interface:ClientHttpConnector
Connect to the origin server using the givenHttpMethod
andURI
and apply the givenrequestCallback
when the HTTP request of the underlying API can be initialized and written to.- Specified by:
connect
in interfaceClientHttpConnector
- Parameters:
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 aMono<Void>
by callingReactiveHttpOutputMessage.writeWith(org.reactivestreams.Publisher<? extends org.springframework.core.io.buffer.DataBuffer>)
orReactiveHttpOutputMessage.setComplete()
.- Returns:
- publisher for the
ClientHttpResponse