diff --git a/web/netty-web/build.gradle b/web/netty-web/build.gradle index fce6d20..727bdb7 100644 --- a/web/netty-web/build.gradle +++ b/web/netty-web/build.gradle @@ -1,5 +1,5 @@ dependencies { implementation project(":") implementation project(":web") - implementation group: "io.netty", name: "netty-all", version: "4.1.33.Final" + implementation group: "io.netty", name: "netty-all", version: "4.1.43.Final" } diff --git a/web/netty-web/src/main/kotlin/cn/tursom/web/netty/NettyHttpContent.kt b/web/netty-web/src/main/kotlin/cn/tursom/web/netty/NettyHttpContent.kt index 1ab6a53..5a5daf1 100644 --- a/web/netty-web/src/main/kotlin/cn/tursom/web/netty/NettyHttpContent.kt +++ b/web/netty-web/src/main/kotlin/cn/tursom/web/netty/NettyHttpContent.kt @@ -18,6 +18,7 @@ open class NettyHttpContent( val ctx: ChannelHandlerContext, val msg: FullHttpRequest ) : AdvanceHttpContent, NettyResponseHeaderAdapter() { + override var finished: Boolean = false override val uri: String by lazy { var uri = msg.uri() while (uri.contains("//")) { @@ -127,6 +128,7 @@ open class NettyHttpContent( } fun finish(response: FullHttpResponse) { + finished = true val heads = response.headers() addHeaders( heads, @@ -159,21 +161,25 @@ open class NettyHttpContent( } override fun finishChunked() { + finished = true val httpChunkWriter = HttpChunkedInput(NettyChunkedByteBuffer(chunkedList)) ctx.writeAndFlush(httpChunkWriter) } override fun finishChunked(chunked: Chunked) { + finished = true val httpChunkWriter = HttpChunkedInput(NettyChunkedInput(chunked)) ctx.writeAndFlush(httpChunkWriter) } override fun finishFile(file: File, chunkSize: Int) { + finished = true writeChunkedHeader() ctx.writeAndFlush(HttpChunkedInput(ChunkedFile(file, chunkSize))) } override fun finishFile(file: RandomAccessFile, offset: Long, length: Long, chunkSize: Int) { + finished = true writeChunkedHeader() ctx.writeAndFlush(HttpChunkedInput(ChunkedFile(file, offset, length, chunkSize))) } diff --git a/web/src/main/kotlin/cn/tursom/web/HttpContent.kt b/web/src/main/kotlin/cn/tursom/web/HttpContent.kt index 83f41f9..7d7d60a 100644 --- a/web/src/main/kotlin/cn/tursom/web/HttpContent.kt +++ b/web/src/main/kotlin/cn/tursom/web/HttpContent.kt @@ -8,6 +8,7 @@ import java.io.RandomAccessFile import java.net.SocketAddress interface HttpContent : ResponseHeaderAdapter, RequestHeaderAdapter { + val finished: Boolean val uri: String var responseCode: Int var responseMessage: String? diff --git a/web/src/main/kotlin/cn/tursom/web/utils/EmptyHttpContent.kt b/web/src/main/kotlin/cn/tursom/web/utils/EmptyHttpContent.kt index 9bde430..5059c8d 100644 --- a/web/src/main/kotlin/cn/tursom/web/utils/EmptyHttpContent.kt +++ b/web/src/main/kotlin/cn/tursom/web/utils/EmptyHttpContent.kt @@ -9,6 +9,7 @@ import java.net.InetSocketAddress import java.net.SocketAddress class EmptyHttpContent( + override val finished: Boolean = true, override val uri: String = "/", override var responseCode: Int = 200, override var responseMessage: String? = null,