«前の日記(2009-01-11(Sun)) 最新 次の日記(2009-01-24(Sat))» 編集

これ日記なん?


2009-01-18(Sun) [長年日記]

_ Rack動かず

Rackを試してみようと思ったら、エラー!?

  • rack 0.9.1
  • rubygems 1.3.1
  • commnad-line
rackup hello.ru
  • hello.ru
require 'hello'
run HelloApp.new
  • hello.rb
require 'rubygems'
require 'rack'

class HelloApp
  def call(env)
    [200, {"Content-Type" => "text/plain"}, ["Hello, Rack"]]
  end
end
  • No Content-Length header found ... Content-Length ヘッダ必須?
[2009-01-18 23:33:48] INFO  WEBrick 1.3.1
[2009-01-18 23:33:48] INFO  ruby 1.8.6 (2008-08-11) [i686-linux]
[2009-01-18 23:33:48] WARN  TCPServer Error: Address family not supported by protocol - socket(2)
[2009-01-18 23:33:48] INFO  WEBrick::HTTPServer#start: pid=12379 port=9292
Rack::Lint::LintError: No Content-Length header found
        /usr/local/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/lint.rb:16:in `assert'
        /usr/local/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/lint.rb:425:in `check_content_length'
        /usr/local/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/lint.rb:52:in `_call'
        /usr/local/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/lint.rb:33:in `call'
        /usr/local/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/showexceptions.rb:23:in `call'
        /usr/local/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/commonlogger.rb:20:in `_call'
        /usr/local/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/commonlogger.rb:13:in `call'
        /usr/local/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/handler/webrick.rb:40:in `service'
        /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
        /usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
        /usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
        /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'
        /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
        /usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'
        /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'
        /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'
        /usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'
        /usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'
        /usr/local/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/handler/webrick.rb:12:in `run'
        /usr/local/lib/ruby/gems/1.8/gems/rack-0.9.1/bin/rackup:172
        /usr/local/bin/rackup:19:in `load'
        /usr/local/bin/rackup:19
192.168.63.1 - - [18/Jan/2009 23:34:14] "GET / HTTP/1.1" 500 61251 0.0780
  • 再チャレンジ
class HelloApp
  def call(env)
    [200, {"Content-Type" => "text/plain", "Content-Length" => 11}, ["Hello, Rack"]]
  end
end
[2009-01-18 23:36:16] INFO  WEBrick 1.3.1
[2009-01-18 23:36:16] INFO  ruby 1.8.6 (2008-08-11) [i686-linux]
[2009-01-18 23:36:16] WARN  TCPServer Error: Address family not supported by protocol - socket(2)
[2009-01-18 23:36:16] INFO  WEBrick::HTTPServer#start: pid=12395 port=9292
Rack::Lint::LintError: header values must respond to #each, but the value of 'Content-Length' doesn't (is Fixnum)
        /usr/local/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/lint.rb:16:in `assert'
        /usr/local/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/lint.rb:342:in `check_headers'
        /usr/local/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/lint.rb:325:in `each'
        /usr/local/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/lint.rb:325:in `check_headers'
        /usr/local/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/lint.rb:49:in `_call'
        /usr/local/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/lint.rb:33:in `call'
        /usr/local/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/showexceptions.rb:23:in `call'
        /usr/local/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/commonlogger.rb:20:in `_call'
        /usr/local/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/commonlogger.rb:13:in `call'
        /usr/local/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/handler/webrick.rb:40:in `service'
        /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
        /usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
        /usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
        /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'
        /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
        /usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'
        /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'
        /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'
        /usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'
        /usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'
        /usr/local/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/handler/webrick.rb:12:in `run'
        /usr/local/lib/ruby/gems/1.8/gems/rack-0.9.1/bin/rackup:172
        /usr/local/bin/rackup:19:in `load'
        /usr/local/bin/rackup:19
192.168.63.1 - - [18/Jan/2009 23:36:20] "GET / HTTP/1.1" 500 67370 0.0828

うーむ...どうしたらよいのだ?

(追記) example/lobster は動いた。なんでだめなんやろう?

本日のツッコミ(全1件) [ツッコミを入れる]
_ kog (2009-01-20(Tue) 20:07)

[200, {"Content-Type" => "text/plain", "Content-Length" => "11"}, ["Hello, Rack"]]