mirror of
https://github.com/tursom/TursomServer.git
synced 2025-01-08 19:30:51 +08:00
修复 NettyHttpContent 返回代码错误的 bug
This commit is contained in:
parent
5d891ad24b
commit
d587e90024
@ -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"
|
||||
}
|
||||
|
@ -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)))
|
||||
}
|
||||
|
@ -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?
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user