-
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
233 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
jooby-netty/src/main/java/org/jooby/internal/netty/NettyHttpAPN.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.jooby.internal.netty; | ||
|
||
import io.netty.channel.ChannelHandlerContext; | ||
import io.netty.channel.ChannelPipeline; | ||
import io.netty.handler.codec.http2.DefaultHttp2Connection; | ||
import io.netty.handler.codec.http2.HttpToHttp2ConnectionHandlerBuilder; | ||
import io.netty.handler.codec.http2.InboundHttp2ToHttpAdapter; | ||
import io.netty.handler.codec.http2.InboundHttp2ToHttpAdapterBuilder; | ||
import io.netty.handler.ssl.ApplicationProtocolNames; | ||
import io.netty.handler.ssl.ApplicationProtocolNegotiationHandler; | ||
|
||
public class NettyHttpAPN extends ApplicationProtocolNegotiationHandler { | ||
|
||
private NettyInitializer initializer; | ||
|
||
public NettyHttpAPN(final NettyInitializer initializer) { | ||
super(ApplicationProtocolNames.HTTP_1_1); | ||
this.initializer = initializer; | ||
} | ||
|
||
@Override | ||
protected void configurePipeline(final ChannelHandlerContext ctx, final String protocol) | ||
throws Exception { | ||
|
||
if (ApplicationProtocolNames.HTTP_2.equals(protocol)) { | ||
DefaultHttp2Connection connection = new DefaultHttp2Connection(true); | ||
InboundHttp2ToHttpAdapter listener = new InboundHttp2ToHttpAdapterBuilder(connection) | ||
.propagateSettings(false) | ||
.validateHttpHeaders(false) | ||
.maxContentLength(initializer.maxContentLength) | ||
.build(); | ||
|
||
ChannelPipeline pipeline = ctx.pipeline(); | ||
pipeline.addLast(new HttpToHttp2ConnectionHandlerBuilder() | ||
.frameListener(listener) | ||
.connection(connection).build()); | ||
initializer.pipeline(pipeline, false); | ||
} else if (ApplicationProtocolNames.HTTP_1_1.equals(protocol)) { | ||
initializer.pipeline(ctx.pipeline(), true); | ||
} else { | ||
throw new IllegalStateException("Unknown protocol: " + protocol); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package netty; | ||
|
||
import org.jooby.Jooby; | ||
|
||
public class H2 extends Jooby { | ||
|
||
{ | ||
http2(); | ||
securePort(8443); | ||
|
||
assets("/assets/**"); | ||
assets("/", "index.html"); | ||
} | ||
|
||
public static void main(final String[] args) throws Throwable { | ||
run(H2::new, args); | ||
} | ||
} |
Oops, something went wrong.