119

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

Community
  • 1
  • 1
AnApprentice
  • 108,152
  • 195
  • 629
  • 1,012
  • 7
    While it may be a duplicate, it does need to grab the rails team attention as it's been over 6 months, and a new version since they acknowledged they needed to clean it up, and yet they still havent. – Jeremy B. Mar 12 '12 at 19:57

3 Answers3

164

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.

Jay Sullivan
  • 17,332
  • 11
  • 62
  • 86
Cam Song
  • 2,956
  • 1
  • 22
  • 18
  • 1
    In your config/environmenst/development.rb, add this line: config.middleware.use Rails::Rack::LogTailer – rtacconi Jun 11 '12 at 15:02
  • 7
    @cam song: almost correct: `rails s thin` will use thin instead of Webrick, and the warn will disappear. – fearless_fool Aug 03 '12 at 03:55
  • 2
    I second using thin instead of WEBrick. However. On Windows the install of the thin dependencies (more specifically the eventmachine) may be problematic. I use the following in my Gemfile to get a clean install of thin: `gem 'eventmachine', '1.0.0.rc.4', :platforms => [:mswin, :mingw]`. **Note**: I installed Rails via the [RailsInstaller](http://railsinstaller.org/) which includes the [DevKit](https://github.com/oneclick/rubyinstaller/wiki/Development-Kit). Might not work without it(?). – Spiralis Aug 29 '12 at 12:30
  • 7
    On Rails 3.2 and above `rails s` will use thin if it exists in the Gemfile. – Brendon Muir Oct 10 '12 at 01:01
  • doesn't work. `puma` worked – Tomasz Nazar Apr 10 '17 at 14:14
28

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!

Anthony
  • 463
  • 5
  • 8
  • 42
    I explicitly added version 1.3.1 of WEBrick to my gemfile and this solved the problem. – Jeremy White Jul 30 '12 at 17:37
  • 10
    Strange: According to the message that displays when I run `rails s`, I was already using WEBrick 1.3.1 (with Rails 3.2.8), but I was still getting the warning messages. I added `gem 'webrick', '1.3.1'` to my gemfile and the warnings stopped. A different version of 1.3.1? – Mark Berry Sep 12 '12 at 16:47
  • 6
    This did NOT fix it for me, perhaps because I am using RVM. wasn't sure where to make this change with RVM. However putting `gem 'webrick', '1.3.1'` in my Gemfile and `bundle install` and restart server worked for me and removed the message. – Michael Durrant Mar 24 '13 at 12:54
9

This patch for WEBrick is also reported to work:

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

Amiel Martin
  • 4,636
  • 1
  • 29
  • 28