现在我的ktor服务器基于netty。
当我对较长的GET请求(大约9300个字符(主要在查询参数中))执行操作时,ktor会回答Unhandled: GET - /bad-request
。
如果我减少url的长度,则可以正常工作。
答案 0 :(得分:0)
在嵌入式服务器配置中,您可以提供函数“ httpServerCodec”来创建HttpServerCodec(https://netty.io/4.1/api/io/netty/handler/codec/http/HttpServerCodec.html),您可以在其中设置maxInitialLineLength属性。
embeddedServer(Netty, configure = {
// Size of the queue to store [ApplicationCall] instances that cannot be immediately processed
requestQueueLimit = 16
// Do not create separate call event group and reuse worker group for processing calls
shareWorkGroup = false
// User-provided function to configure Netty's [ServerBootstrap]
configureBootstrap = {
// ...
}
httpServerCodec = {
HttpServerCodec(.......)
}
// Timeout in seconds for sending responses to client
responseWriteTimeoutSeconds = 10
}) {
// ...
}.start(true)