Ruby-on-rails WARN 无法确定响应正文的内容长度。设置响应的内容长度或设置 Response#chunked = true

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9612618/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 02:59:35  来源:igfitidea点击:

WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true

ruby-on-railsruby-on-rails-3

提问by AnApprentice

Possible Duplicate:
What does “WARN Could not determine content-length of response body.” mean and how to I get rid of it?

可能的重复:
“WARN 无法确定响应正文的内容长度”是什么意思。意思是我如何摆脱它?

I just upgraded to rails 3.2.2, and now on rails s, page load, I get all these errors in the log:

我刚刚升级到 rails 3.2.2,现在在 rails s,页面加载上,我在日志中收到所有这些错误:

[2012-03-07 19:46:14] WARN  Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
[2012-03-07 19:46:14] WARN  Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true

Per previous SO threads, I tried the following:

根据之前的 SO 线程,我尝试了以下操作:

/config/application.rb

/配置/应用程序.rb

config.assets.logger = false
config.assets.logger = nil

None of these worked. Any ideas on how to disable this logging for this error? Or to fix the issue :)

这些都没有奏效。关于如何为此错误禁用此日志记录的任何想法?或解决问题:)

Thanks

谢谢

回答by Cam Song

This is a problem of Webrick. you can use "Thin" instead.

这是 Webrick 的一个问题。您可以改用“瘦”。

Add this to Gemfile

将此添加到 Gemfile

gem 'thin'

then rails swill use thin instead of Webrick, and the warn will disappear.

然后rails s将使用 Thin 而不是 Webrick,警告将消失。

回答by Anthony

Patch mentioned by Amiel Martin works for me! Just find your webrick path (ex., c:\Ruby\lib\ruby\1.9.1\webrick\ on Windows) and change httpresponse.rbfile as described in https://bugs.ruby-lang.org/attachments/2300/204_304_keep_alive.patch

Amiel Martin 提到的补丁对我有用!只需找到您的 webrick 路径(例如,c:\Ruby\lib\ruby\1.9.1\webrick\ 在 Windows 上)并按照https://bugs.ruby-lang.org/attachments/ 中的描述更改httpresponse.rb文件2300/204_304_keep_alive.patch

And don't forget restart Webrick!

并且不要忘记重启Webrick!

回答by Amiel Martin

This patch for WEBrick is also reported to work:

据报道,这个 WEBrick 补丁也可以工作:

https://bugs.ruby-lang.org/attachments/2300/204_304_keep_alive.patch

https://bugs.ruby-lang.org/attachments/2300/204_304_keep_alive.patch