Java Code Examples for io.netty.handler.codec.http.HttpServerUpgradeHandler#UpgradeEvent
The following examples show how to use
io.netty.handler.codec.http.HttpServerUpgradeHandler#UpgradeEvent .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Http2FrameCodecTest.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
@Test public void upgradeEventNoRefCntError() throws Exception { frameListener.onHeadersRead(http2HandlerCtx, Http2CodecUtil.HTTP_UPGRADE_STREAM_ID, request, 31, false); // Using reflect as the constructor is package-private and the class is final. Constructor<UpgradeEvent> constructor = UpgradeEvent.class.getDeclaredConstructor(CharSequence.class, FullHttpRequest.class); // Check if we could make it accessible which may fail on java9. Assume.assumeTrue(ReflectionUtil.trySetAccessible(constructor, true) == null); HttpServerUpgradeHandler.UpgradeEvent upgradeEvent = constructor.newInstance( "HTTP/2", new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/")); channel.pipeline().fireUserEventTriggered(upgradeEvent); assertEquals(1, upgradeEvent.refCnt()); }
Example 2
Source File: HelloWorldHttp2Handler.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
/** * Handles the cleartext HTTP upgrade event. If an upgrade occurred, sends a simple response via HTTP/2 * on stream 1 (the stream specifically reserved for cleartext HTTP upgrade). */ @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof HttpServerUpgradeHandler.UpgradeEvent) { HttpServerUpgradeHandler.UpgradeEvent upgradeEvent = (HttpServerUpgradeHandler.UpgradeEvent) evt; onHeadersRead(ctx, 1, http1HeadersToHttp2Headers(upgradeEvent.upgradeRequest()), 0 , true); } super.userEventTriggered(ctx, evt); }
Example 3
Source File: HelloWorldHttp2Handler.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
/** * Handles the cleartext HTTP upgrade event. If an upgrade occurred, sends a simple response via HTTP/2 * on stream 1 (the stream specifically reserved for cleartext HTTP upgrade). */ @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof HttpServerUpgradeHandler.UpgradeEvent) { HttpServerUpgradeHandler.UpgradeEvent upgradeEvent = (HttpServerUpgradeHandler.UpgradeEvent) evt; onHeadersRead(ctx, 1, http1HeadersToHttp2Headers(upgradeEvent.upgradeRequest()), 0 , true); } super.userEventTriggered(ctx, evt); }
Example 4
Source File: Http2Handler.java From product-microgateway with Apache License 2.0 | 5 votes |
/** * Handles the cleartext HTTP upgrade event. If an upgrade occurred, sends a simple response via HTTP/2 * on stream 1 (the stream specifically reserved for cleartext HTTP upgrade). * * @param ctx - Context of the ChannelHandler * @param evt - HTTP upgrade event * @throws java.lang.Exception If an error occurs while upgrading the event */ @Override public void userEventTriggered (ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof HttpServerUpgradeHandler.UpgradeEvent) { HttpServerUpgradeHandler.UpgradeEvent upgradeEvent = (HttpServerUpgradeHandler.UpgradeEvent) evt; onHeadersRead(ctx, 1, http1HeadersToHttp2Headers(upgradeEvent.upgradeRequest()), 0, true); } super.userEventTriggered(ctx, evt); }
Example 5
Source File: Http2ServerChannelHandler.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { /* * Handles the cleartext HTTP upgrade event. If an upgrade occurred, sends a simple response via HTTP/2 * on stream 1 (the stream specifically reserved for cleartext HTTP upgrade). */ if (evt instanceof HttpServerUpgradeHandler.UpgradeEvent) { HttpServerUpgradeHandler.UpgradeEvent upgradeEvent = (HttpServerUpgradeHandler.UpgradeEvent) evt; this.isUpgradeH2cMode = true; onHeadersRead(ctx, 1, http1HeadersToHttp2Headers(upgradeEvent.upgradeRequest()), 0, true); } super.userEventTriggered(ctx, evt); }