17
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Posted at

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

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

17
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?