tcpClient = tcpClient.proxy(proxySpec -> { ProxyProvider.Builder builder = proxySpec .type(ProxyProvider.Proxy.HTTP)
@Test public void proxy_2() { StepVerifier.create( HttpClient.create() .tcpConfiguration(tcpClient -> tcpClient.proxy(ops -> ops.type(ProxyProvider.Proxy.HTTP) .host("localhost") .port(hoverflyRule.getProxyPort()))) .wiretap(true) .get() .uri("http://127.0.0.1:7000/") .responseSingle((response, body) -> Mono.zip(body.asString(), Mono.just(response.responseHeaders())))) .expectNextMatches(t -> t.getT2().contains("Hoverfly") && "test".equals(t.getT1())) .expectComplete() .verify(Duration.ofSeconds(30)); }
@Test public void proxy_1() { StepVerifier.create( HttpClient.create() .tcpConfiguration(tcpClient -> tcpClient.proxy(ops -> ops.type(ProxyProvider.Proxy.HTTP) .host("localhost") .port(hoverflyRule.getProxyPort()))) .addressSupplier(server::address) .wiretap(true) .get() .uri("/") .responseSingle((response, body) -> Mono.zip(body.asString(), Mono.just(response.responseHeaders())))) .expectNextMatches(t -> t.getT2().contains("Hoverfly") && "test".equals(t.getT1())) .expectComplete() .verify(Duration.ofSeconds(30)); }
@Test public void nonProxyHosts_2() { StepVerifier.create( HttpClient.create() .tcpConfiguration(tcpClient -> tcpClient.proxy(ops -> ops.type(ProxyProvider.Proxy.HTTP) .host("localhost") .port(hoverflyRule.getProxyPort()) .nonProxyHosts("localhost"))) .wiretap(true) .get() .uri("http://localhost:7000/") .responseSingle((response, body) -> Mono.zip(body.asString(), Mono.just(response.responseHeaders())))) .expectNextMatches(t -> !t.getT2().contains("Hoverfly") && "test".equals(t.getT1())) .expectComplete() .verify(Duration.ofSeconds(30)); } }
@Test public void nonProxyHosts_1() { StepVerifier.create( HttpClient.create() .tcpConfiguration(tcpClient -> tcpClient.proxy(ops -> ops.type(ProxyProvider.Proxy.HTTP) .host("localhost") .port(hoverflyRule.getProxyPort()) .nonProxyHosts("127.0.0.1"))) .addressSupplier(server::address) .wiretap(true) .get() .uri("/") .responseSingle((response, body) -> Mono.zip(body.asString(), Mono.just(response.responseHeaders())))) .expectNextMatches(t -> !t.getT2().contains("Hoverfly") && "test".equals(t.getT1())) .expectComplete() .verify(Duration.ofSeconds(30)); }