【问题标题】:Thin server QUERY_STRING is longer than the (1024 * 10) allowed length瘦服务器 QUERY_STRING 长于 (1024 * 10) 允许的长度
【发布时间】:2015-10-14 18:13:09
【问题描述】:
如何在 Rails 中使用 thin、puma 或 unicorn Web 服务器增加 QUERY_STRING 的最大允许值?我正在尝试向我的 Rails API 发出超过限制的 POST 请求,只需要增加服务器的最大阈值
POST 的具体错误:Invalid request: HTTP element QUERY_STRING is longer than the (1024 * 10) allowed length.
我只在另一个地方 (HTTP query string length with thin web server) 遇到过这个问题,我不太明白答案(具体来说,在哪里可以找到要在该答案中编辑的 C 文件?)
【问题讨论】:
标签:
ruby-on-rails
unicorn
thin
puma
【解决方案1】:
你会在 ~/.rvm/gems/ruby-2.2.0/gems/thin-1.6.4/ext/thin_parser 之类的地方找到thin.c
你会想要改变
DEF_MAX_LENGTH(REQUEST_URI, 1024 * 12);
...
DEF_MAX_LENGTH(QUERY_STRING, (1024 * 10));
在同一个文件夹中,您只需要使用 Makefile 重新加载 thin_parser.so,并将之前的 thin_parser.so 替换为 ~/.rvm/gems/ruby-2.2.0/gems/thin 中的新文件-1.6.4/lib(好像Makefile自己没有做)
make clean && make && cp thin_parser.so ../../lib/
我就是这样弄的,希望对你有帮助
【解决方案2】:
有问题的文件位于 gem 源代码中的 /ext/thin_parser/thin.c 中。要进行您想要的更改,我相信最简单的方法是在 Github 上 fork 这个 gem,在您的 fork 中发布您的更改,然后使用 Gemfile 中的 git: 选项捆绑您的版本。喜欢:
gem 'thin', git: '<URL to your fork>', branch: '<branch of fork to use>'