use of org.springframework.http.client.reactive.ReactorClientHttpConnector in project pinpoint by naver.
the class SpringWebfluxPluginController method clientUnknown.
@GetMapping("/client/unknown")
public Mono<String> clientUnknown() {
WebClient client = WebClient.builder().clientConnector(new ReactorClientHttpConnector()).baseUrl("http://falfjlajdflajflajlf").build();
// WebClient client = WebClient.create("http://falfjlajdflajflajlf");
WebClient.ResponseSpec response = client.method(HttpMethod.GET).uri("").retrieve();
return response.bodyToMono(String.class);
}
use of org.springframework.http.client.reactive.ReactorClientHttpConnector in project spring-boot by spring-projects.
the class NettyReactiveWebServerFactoryTests method testSslWithAlias.
protected Mono<String> testSslWithAlias(String alias) {
String keyStore = "classpath:test.jks";
String keyPassword = "password";
NettyReactiveWebServerFactory factory = getFactory();
Ssl ssl = new Ssl();
ssl.setKeyStore(keyStore);
ssl.setKeyPassword(keyPassword);
ssl.setKeyAlias(alias);
factory.setSsl(ssl);
this.webServer = factory.getWebServer(new EchoHandler());
this.webServer.start();
ReactorClientHttpConnector connector = buildTrustAllSslConnector();
WebClient client = WebClient.builder().baseUrl("https://localhost:" + this.webServer.getPort()).clientConnector(connector).build();
return client.post().uri("/test").contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromValue("Hello World")).retrieve().bodyToMono(String.class);
}
use of org.springframework.http.client.reactive.ReactorClientHttpConnector in project spring-boot by spring-projects.
the class AbstractReactiveWebServerFactoryTests method testBasicSslWithKeyStore.
protected final void testBasicSslWithKeyStore(String keyStore, String keyPassword) {
AbstractReactiveWebServerFactory factory = getFactory();
Ssl ssl = new Ssl();
ssl.setKeyStore(keyStore);
ssl.setKeyPassword(keyPassword);
ssl.setKeyStorePassword("secret");
factory.setSsl(ssl);
this.webServer = factory.getWebServer(new EchoHandler());
this.webServer.start();
ReactorClientHttpConnector connector = buildTrustAllSslConnector();
WebClient client = WebClient.builder().baseUrl("https://localhost:" + this.webServer.getPort()).clientConnector(connector).build();
Mono<String> result = client.post().uri("/test").contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromValue("Hello World")).retrieve().bodyToMono(String.class);
assertThat(result.block(Duration.ofSeconds(30))).isEqualTo("Hello World");
}
use of org.springframework.http.client.reactive.ReactorClientHttpConnector in project spring-boot by spring-projects.
the class AbstractReactiveWebServerFactoryTests method buildTrustAllSslWithClientKeyConnector.
protected ReactorClientHttpConnector buildTrustAllSslWithClientKeyConnector() throws Exception {
KeyStore clientKeyStore = KeyStore.getInstance(KeyStore.getDefaultType());
try (InputStream stream = new FileInputStream("src/test/resources/test.jks")) {
clientKeyStore.load(stream, "secret".toCharArray());
}
KeyManagerFactory clientKeyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
clientKeyManagerFactory.init(clientKeyStore, "password".toCharArray());
Http11SslContextSpec sslContextSpec = Http11SslContextSpec.forClient().configure((builder) -> builder.sslProvider(SslProvider.JDK).trustManager(InsecureTrustManagerFactory.INSTANCE).keyManager(clientKeyManagerFactory));
HttpClient client = HttpClient.create().wiretap(true).secure((spec) -> spec.sslContext(sslContextSpec));
return new ReactorClientHttpConnector(client);
}
use of org.springframework.http.client.reactive.ReactorClientHttpConnector in project spring-boot by spring-projects.
the class AbstractReactiveWebServerFactoryTests method sslWithValidAlias.
@Test
void sslWithValidAlias() {
String keyStore = "classpath:test.jks";
String keyPassword = "password";
AbstractReactiveWebServerFactory factory = getFactory();
Ssl ssl = new Ssl();
ssl.setKeyStore(keyStore);
ssl.setKeyStorePassword("secret");
ssl.setKeyPassword(keyPassword);
ssl.setKeyAlias("test-alias");
factory.setSsl(ssl);
this.webServer = factory.getWebServer(new EchoHandler());
this.webServer.start();
ReactorClientHttpConnector connector = buildTrustAllSslConnector();
WebClient client = WebClient.builder().baseUrl("https://localhost:" + this.webServer.getPort()).clientConnector(connector).build();
Mono<String> result = client.post().uri("/test").contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromValue("Hello World")).retrieve().bodyToMono(String.class);
StepVerifier.setDefaultTimeout(Duration.ofSeconds(30));
StepVerifier.create(result).expectNext("Hello World").verifyComplete();
}
Aggregations