Search in sources :

Example 1 with HttpClientResponse

use of reactor.netty.http.client.HttpClientResponse 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 HttpClientResponse

use of reactor.netty.http.client.HttpClientResponse in project reactor-netty by reactor.

the class TracingChannelInboundHandler method channelRead.

@Override
@SuppressWarnings("try")
public void channelRead(ChannelHandlerContext ctx, Object msg) {
    Span span = ctx.channel().attr(SPAN_ATTR_KEY).get();
    if (span != null) {
        try (Scope scope = currentTraceContext.maybeScope(span.context())) {
            ctx.fireChannelRead(msg);
        }
        return;
    } else {
        ChannelOperations<?, ?> ops = ChannelOperations.get(ctx.channel());
        if (ops instanceof HttpClientResponse) {
            TraceContext parent = ((HttpClientResponse) ops).currentContextView().getOrDefault(TraceContext.class, null);
            if (parent != null) {
                try (Scope scope = currentTraceContext.maybeScope(parent)) {
                    ctx.fireChannelRead(msg);
                }
                return;
            }
        }
    }
    ctx.fireChannelRead(msg);
}
Also used : Scope(brave.propagation.CurrentTraceContext.Scope) HttpClientResponse(reactor.netty.http.client.HttpClientResponse) CurrentTraceContext(brave.propagation.CurrentTraceContext) TraceContext(brave.propagation.TraceContext) Span(brave.Span)

Aggregations

HttpClientResponse (reactor.netty.http.client.HttpClientResponse)2 Span (brave.Span)1 CurrentTraceContext (brave.propagation.CurrentTraceContext)1 Scope (brave.propagation.CurrentTraceContext.Scope)1 TraceContext (brave.propagation.TraceContext)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 HttpClient (reactor.netty.http.client.HttpClient)1