Hello all,
(I''m using Webrick and Rails 0.13)
I have an application where I don''t need sessions, so I followed the
instructions on
http://wiki.rubyonrails.com/rails/show/HowtoChangeSessionOptions and
set
ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS=false
in my environment.rb file to de-activate them.
I restarted webrick and I got this error the first time I made a request:
#<TypeError: cannot convert nil into Array>
["e:/ruby/lib/ruby/gems/1.8/gems/rails-0.13.0/lib/webrick_server.rb:111:in
`concat''",
"e:/ruby/lib/ruby/gems/1.8/gems/rails-0.13.0/lib/webrick_server.rb:111:in
`handle_dispatch''",
"e:/ruby/lib/ruby/gems/1.8/gems/rails-0.13.0/lib/webrick_server.rb:69:in
`service''",
"e:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in
`service''",
"e:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run''",
"e:/ruby/lib/ruby/1.8/webrick/server.rb:155:in
`start_thread''",
"e:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start''",
"e:/ruby/lib/ruby/1.8/webrick/server.rb:144:in
`start_thread''",
"e:/ruby/lib/ruby/1.8/webrick/server.rb:94:in `start''",
"e:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `each''",
"e:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `start''",
"e:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start''",
"e:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start''",
"e:/ruby/lib/ruby/gems/1.8/gems/rails-0.13.0/lib/webrick_server.rb:55:in
`dispatch''",
"script/server:49"]
This is the code in webrick_server.rb around line 111:
101 def handle_dispatch(req, res, origin = nil)
102 data = StringIO.new
103 Dispatcher.dispatch(
104 CGI.new("query", create_env_table(req, origin),
StringIO.new(req.body || "")),
105 ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS,
106 data
107 )
108
109 header, body = extract_header_and_body(data)
110 assign_status(res, header)
111 res.cookies.concat(header.delete(''set-cookie''))
... [...]
122 end
What I understood is the following:
1. At line 103, Dispatcher.dispatch is called with false as his second
argument (line 105);
2. This argument being false, no session will be created and no
''set-cookie'' header will be added to the HTTP response;
3. At line 111, the delete call on the header object (which is a hash)
will return nil, because there is no ''set-cookie'' header and
because
Hash#delete returns the hash default value (which is nil by default)
when the key passed as parameter doesn''t exist
4. res.cookies.concat fails because it receives nil as parameter
So I changed line 111 to the following and everything worked well:
res.cookies.concat(header.delete(''set-cookie''))
if(header.has_key?(''set-cookie''))
Is this correct?
(I''m using Rails 0.13)
Thanks
- Xavier