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

Ruby on-Rails Problem Overview


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

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

[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:

/config/application.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

Ruby on-Rails Solutions


Solution 1 - Ruby on-Rails

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

Add this to Gemfile

gem 'thin'

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

Solution 2 - Ruby on-Rails

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.rb file as described in https://bugs.ruby-lang.org/attachments/2300/204_304_keep_alive.patch

And don't forget restart Webrick!

Solution 3 - Ruby on-Rails

This patch for WEBrick is also reported to work:

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAnApprenticeView Question on Stackoverflow
Solution 1 - Ruby on-RailsCam SongView Answer on Stackoverflow
Solution 2 - Ruby on-RailsAnthonyView Answer on Stackoverflow
Solution 3 - Ruby on-RailsAmiel MartinView Answer on Stackoverflow