-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
1 parent
b058d9b
commit 60700bf
Showing
7 changed files
with
79 additions
and
85 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
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
34 changes: 34 additions & 0 deletions
34
...tp_server_netty/src/main/kotlin/com/hexagonkt/http/server/netty/HttpChannelInitializer.kt
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,34 @@ | ||
package com.hexagonkt.http.server.netty | ||
|
||
import com.hexagonkt.http.handlers.HttpHandler | ||
import com.hexagonkt.http.server.HttpServerSettings | ||
import io.netty.channel.ChannelInitializer | ||
import io.netty.channel.socket.SocketChannel | ||
import io.netty.handler.codec.http.* | ||
import io.netty.handler.stream.ChunkedWriteHandler | ||
import io.netty.util.concurrent.EventExecutorGroup | ||
|
||
internal class HttpChannelInitializer( | ||
private val handlers: Map<HttpMethod, HttpHandler>, | ||
private val executorGroup: EventExecutorGroup?, | ||
private val settings: HttpServerSettings, | ||
) : ChannelInitializer<SocketChannel>() { | ||
|
||
override fun initChannel(channel: SocketChannel) { | ||
val pipeline = channel.pipeline() | ||
|
||
pipeline.addLast(HttpServerCodec()) | ||
// pipeline.addLast(HttpServerKeepAliveHandler()) | ||
pipeline.addLast(HttpObjectAggregator(Int.MAX_VALUE)) | ||
// pipeline.addLast(ChunkedWriteHandler()) | ||
|
||
if (settings.zip) | ||
pipeline.addLast(HttpContentCompressor()) | ||
|
||
val nettyServerHandler = NettyServerHandler(handlers, null) | ||
if (executorGroup == null) | ||
pipeline.addLast(nettyServerHandler) | ||
else | ||
pipeline.addLast(executorGroup, nettyServerHandler) | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...p_server_netty/src/main/kotlin/com/hexagonkt/http/server/netty/HttpsChannelInitializer.kt
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,40 @@ | ||
package com.hexagonkt.http.server.netty | ||
|
||
import com.hexagonkt.http.SslSettings | ||
import com.hexagonkt.http.handlers.HttpHandler | ||
import com.hexagonkt.http.server.HttpServerSettings | ||
import io.netty.channel.ChannelInitializer | ||
import io.netty.channel.socket.SocketChannel | ||
import io.netty.handler.codec.http.* | ||
import io.netty.handler.ssl.SslContext | ||
import io.netty.util.concurrent.EventExecutorGroup | ||
|
||
internal class HttpsChannelInitializer( | ||
private val handlers: Map<HttpMethod, HttpHandler>, | ||
private val sslContext: SslContext, | ||
private val sslSettings: SslSettings, | ||
private val executorGroup: EventExecutorGroup?, | ||
private val settings: HttpServerSettings, | ||
) : ChannelInitializer<SocketChannel>() { | ||
|
||
override fun initChannel(channel: SocketChannel) { | ||
val pipeline = channel.pipeline() | ||
val sslHandler = sslContext.newHandler(channel.alloc()) | ||
val handlerSsl = if (sslSettings.clientAuth) sslHandler else null | ||
|
||
pipeline.addLast(sslHandler) | ||
pipeline.addLast(HttpServerCodec()) | ||
// pipeline.addLast(HttpServerKeepAliveHandler()) | ||
pipeline.addLast(HttpObjectAggregator(Int.MAX_VALUE)) | ||
// pipeline.addLast(ChunkedWriteHandler()) | ||
|
||
if (settings.zip) | ||
pipeline.addLast(HttpContentCompressor()) | ||
|
||
val serverHandler = NettyServerHandler(handlers, handlerSsl) | ||
if (executorGroup == null) | ||
pipeline.addLast(serverHandler) | ||
else | ||
pipeline.addLast(executorGroup, serverHandler) | ||
} | ||
} |
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