【问题标题】:How to increase max length of acceptable url for ktor?如何增加 ktor 可接受 url 的最大长度?
【发布时间】:2019-08-05 06:27:06
【问题描述】:

现在我的 ktor 服务器是基于 netty 的。 当我执行长 GET 请求(大约 9300 个字符(主要在查询参数中))时,ktor 回答 Unhandled: GET - /bad-request。 如果我减少 url 的长度,它工作正常。

【问题讨论】:

    标签: kotlin netty ktor


    【解决方案1】:

    在您的嵌入式服务器配置中,您可以提供一个函数“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)
    

    【讨论】:

      猜你喜欢
      • 2017-07-03
      • 2015-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-15
      • 2014-08-08
      • 2011-03-20
      • 1970-01-01
      相关资源
      最近更新 更多