use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpRequest in project pinpoint by naver.
the class NettyIT method writeTest.
@Test
public void writeTest() throws Exception {
final CountDownLatch awaitLatch = new CountDownLatch(1);
EventLoopGroup workerGroup = new NioEventLoopGroup(2);
Bootstrap bootstrap = client(workerGroup);
final ChannelFuture connect = bootstrap.connect(webServer.getHostname(), webServer.getListeningPort());
connect.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
if (future.isSuccess()) {
Channel channel = future.channel();
channel.pipeline().addLast(new SimpleChannelInboundHandler() {
@Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) {
awaitLatch.countDown();
}
});
HttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/");
future.channel().writeAndFlush(request);
}
}
});
boolean await = awaitLatch.await(3000, TimeUnit.MILLISECONDS);
Assert.assertTrue(await);
final Channel channel = connect.channel();
try {
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
verifier.printCache();
verifier.verifyTrace(event("NETTY", Bootstrap.class.getMethod("connect", SocketAddress.class), annotation("netty.address", webServer.getHostAndPort())));
verifier.verifyTrace(event("NETTY", "io.netty.channel.DefaultChannelPromise.addListener(io.netty.util.concurrent.GenericFutureListener)"));
verifier.verifyTrace(event("ASYNC", "Asynchronous Invocation"));
verifier.verifyTrace(event("NETTY_INTERNAL", "io.netty.util.concurrent.DefaultPromise.notifyListenersNow()"));
verifier.verifyTrace(event("NETTY_INTERNAL", "io.netty.util.concurrent.DefaultPromise.notifyListener0(io.netty.util.concurrent.Future, io.netty.util.concurrent.GenericFutureListener)"));
verifier.verifyTrace(event("NETTY", "io.netty.channel.DefaultChannelPipeline.writeAndFlush(java.lang.Object)"));
verifier.verifyTrace(event("NETTY_HTTP", "io.netty.handler.codec.http.HttpObjectEncoder.encode(io.netty.channel.ChannelHandlerContext, java.lang.Object, java.util.List)", annotation("http.url", "/")));
} finally {
channel.close().sync();
workerGroup.shutdown();
}
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpRequest in project pinpoint by naver.
the class Http1xClientConnectionCreateRequestInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args, result, throwable);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
if (!trace.canSampled()) {
if (result instanceof HttpRequest) {
final HttpRequest request = (HttpRequest) result;
requestTraceWriter.write(request);
}
return;
}
try {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordApi(descriptor);
recorder.recordException(throwable);
recorder.recordServiceType(VertxConstants.VERTX_HTTP_CLIENT);
if (!validate(args, result)) {
return;
}
final HttpRequest request = (HttpRequest) result;
final HttpHeaders headers = request.headers();
if (headers == null) {
return;
}
String host = ArrayArgumentUtils.getArgument(args, 4, String.class, "UNKNOWN");
// generate next trace id.
final TraceId nextId = trace.getTraceId().getNextTraceId();
recorder.recordNextSpanId(nextId.getSpanId());
requestTraceWriter.write(request, nextId, host);
final ClientRequestWrapper clientRequest = new VertxHttpClientRequestWrapper(request, host);
this.clientRequestRecorder.record(recorder, clientRequest, throwable);
this.cookieRecorder.record(recorder, request, throwable);
} catch (Throwable t) {
if (logger.isWarnEnabled()) {
logger.warn("AFTER. Caused:{}", t.getMessage(), t);
}
} finally {
trace.traceBlockEnd();
}
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpRequest in project pinpoint by naver.
the class HttpClientStreamInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
try {
final SpanEventRecorder recorder = trace.traceBlockBegin();
if (!validate(args)) {
return;
}
final HttpRequest request = (HttpRequest) args[0];
final HttpHeaders headers = request.headers();
if (headers == null) {
// defense code.
return;
}
final String host = (String) args[1];
// generate next trace id.
final TraceId nextId = trace.getTraceId().getNextTraceId();
recorder.recordNextSpanId(nextId.getSpanId());
requestTraceWriter.write(request, nextId, host);
} catch (Throwable t) {
if (logger.isWarnEnabled()) {
logger.warn("BEFORE. Caused:{}", t.getMessage(), t);
}
}
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpRequest in project pinpoint by naver.
the class HttpClientStreamInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args, result, throwable);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
try {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordApi(descriptor);
recorder.recordException(throwable);
recorder.recordServiceType(VertxConstants.VERTX_HTTP_CLIENT);
if (!validate(args)) {
return;
}
final HttpRequest request = (HttpRequest) args[0];
final HttpHeaders headers = request.headers();
if (headers == null) {
return;
}
final String host = (String) args[1];
ClientRequestWrapper clientRequest = new VertxHttpClientRequestWrapper(request, host);
this.clientRequestRecorder.record(recorder, clientRequest, throwable);
this.cookieRecorder.record(recorder, request, throwable);
} catch (Throwable t) {
if (logger.isWarnEnabled()) {
logger.warn("AFTER. Caused:{}", t.getMessage(), t);
}
} finally {
trace.traceBlockEnd();
}
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpRequest in project netty by netty.
the class WebSocketServerCompressionHandlerTest method testServerWindowSizeDisable.
@Test
public void testServerWindowSizeDisable() {
EmbeddedChannel ch = new EmbeddedChannel(new WebSocketServerExtensionHandler(new PerMessageDeflateServerExtensionHandshaker(6, false, 15, false, false)));
HttpRequest req = newUpgradeRequest(PERMESSAGE_DEFLATE_EXTENSION + "; " + SERVER_MAX_WINDOW + "=10");
ch.writeInbound(req);
HttpResponse res = newUpgradeResponse(null);
ch.writeOutbound(res);
HttpResponse res2 = ch.readOutbound();
assertFalse(res2.headers().contains(HttpHeaderNames.SEC_WEBSOCKET_EXTENSIONS));
assertNull(ch.pipeline().get(PerMessageDeflateDecoder.class));
assertNull(ch.pipeline().get(PerMessageDeflateEncoder.class));
}
Aggregations