Search in sources :

Example 1 with HttpClient

use of reactor.netty.http.client.HttpClient in project pinpoint by naver.

the class ReactorNettyPluginTestController method clientPost.

@RequestMapping(value = "/client/post", method = RequestMethod.GET)
@ResponseBody
public String clientPost() {
    HttpClient client = HttpClient.create().port(80);
    HttpClientResponse response = client.post().uri("https://www.google.com/").send(ByteBufFlux.fromString(Mono.just("hello"))).response().block();
    return response.toString();
}
Also used : HttpClient(reactor.netty.http.client.HttpClient) HttpClientResponse(reactor.netty.http.client.HttpClientResponse) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with HttpClient

use of reactor.netty.http.client.HttpClient in project pinpoint by naver.

the class ReactorNettyPluginTestController method clientGet.

@RequestMapping(value = "/client/get", method = RequestMethod.GET)
@ResponseBody
public String clientGet() {
    HttpClient client = HttpClient.create().port(80);
    String response = client.get().uri("https://www.google.com?foo=bar").responseContent().aggregate().asString().block();
    return response;
}
Also used : HttpClient(reactor.netty.http.client.HttpClient) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with HttpClient

use of reactor.netty.http.client.HttpClient in project pinpoint by naver.

the class ReactorNettyPluginTestController method clientError.

@RequestMapping(value = "/client/local", method = RequestMethod.GET)
@ResponseBody
public String clientError(HttpServletRequest request) {
    HttpClient client = HttpClient.create().port(request.getLocalPort());
    String response = client.get().uri("/client/echo").responseContent().aggregate().asString().block();
    return response;
}
Also used : HttpClient(reactor.netty.http.client.HttpClient) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with HttpClient

use of reactor.netty.http.client.HttpClient in project pinpoint by naver.

the class ReactorNettyPluginTestController method clientError.

@RequestMapping(value = "/client/unknown", method = RequestMethod.GET)
@ResponseBody
public String clientError() {
    HttpClient client = HttpClient.create().port(80);
    String response = client.get().uri("http://fjalkjdlfaj.com").responseContent().aggregate().asString().block();
    return response;
}
Also used : HttpClient(reactor.netty.http.client.HttpClient) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with HttpClient

use of reactor.netty.http.client.HttpClient in project spring-boot by spring-projects.

the class AbstractReactiveWebServerFactoryTests method prepareCompressionTest.

protected WebClient prepareCompressionTest(Compression compression, String responseContentType) {
    AbstractReactiveWebServerFactory factory = getFactory();
    factory.setCompression(compression);
    this.webServer = factory.getWebServer(new CharsHandler(3000, responseContentType));
    this.webServer.start();
    HttpClient client = HttpClient.create().wiretap(true).compress(true).doOnConnected((connection) -> connection.channel().pipeline().addBefore(NettyPipeline.HttpDecompressor, "CompressionTest", new CompressionDetectionHandler()));
    return getWebClient(client, this.webServer.getPort()).build();
}
Also used : HttpClient(reactor.netty.http.client.HttpClient)

Aggregations

HttpClient (reactor.netty.http.client.HttpClient)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 ReactorClientHttpConnector (org.springframework.http.client.reactive.ReactorClientHttpConnector)3 Http11SslContextSpec (reactor.netty.http.Http11SslContextSpec)3 SslContextBuilder (io.netty.handler.ssl.SslContextBuilder)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 KeyStore (java.security.KeyStore)1 KeyManagerFactory (javax.net.ssl.KeyManagerFactory)1 HttpClientResponse (reactor.netty.http.client.HttpClientResponse)1