14
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

Organization

Railsサーバーの`WARN Could not determine content-length…`のログを表示しないようにする

Webrickのログに、
WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = trueていう警告がいっぱい出ていて鬱陶しかったので、表示しないようにした。

このページに載ってる通りにやっただけ。
https://bugs.ruby-lang.org/attachments/2300/204_304_keep_alive.patch

環境

  • ruby 1.9.3p392 (rbenvとruby-buildで入れたやつ)
  • Rails 3.2.11

方法

~/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/webrick/httpresponse.rbを1行編集するだけで良いらしい。

~/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/webrick/httpresponse.rb
# 205行目あたり
# if chunked? || @header['content-length'] (編集前)
if chunked? || @header['content-length'] || @status == 304 || @status == 204  # 編集後       
  @header['connection'] = "Keep-Alive"
else

サーバー再起動したら警告ログが出なくなった。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
14
Help us understand the problem. What are the problem?