rack/rack — Issue #275: RuntimeError: cannot parse Cookie header
Author: aia
Created: 2011-11-26 21:06:53+00:00
State: open

The setup:

ruby --version
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]

rvm --version
rvm 1.9.2 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]

Latest rack:

gem list | grep rack
rack (1.4.0)
rack-protection (1.1.4)

Simple App:

config.ru

===

require 'rack'
require 'sinatra/base'

class HTTPConnection < Sinatra::Base
get '/' do
"Test"
end
end

@app = Rack::Builder.new {
use Rack::Session::Pool, :key => 'cookietest.session', :expire_after => 60000
use Rack::ShowExceptions
use Rack::Lint
run Rack::Cascade.new([HTTPConnection])
}.to_app

run @app

===

rackup

[2011-11-26 12:59:57] INFO WEBrick 1.3.1
[2011-11-26 12:59:57] INFO ruby 1.9.3 (2011-10-30) [x86_64-darwin11.2.0]
[2011-11-26 12:59:57] INFO WEBrick::HTTPServer#start: pid=46895 port=9292

curl http://localhost:9292

Results in the following:

RuntimeError: cannot parse Cookie header: can't add a new key into hash during iteration
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/request.rb:265:in `rescue in cookies'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/request.rb:250:in `cookies'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:244:in `extract_session_id'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:43:in `load_session_id!'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:32:in `[]'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:252:in `current_session_id'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:258:in `session_exists?'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:104:in `exists?'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:114:in `load_for_read!'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:98:in `inspect'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/lint.rb:65:in `inspect'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/lint.rb:65:in `check_env'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/lint.rb:42:in `_call'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/lint.rb:36:in `call'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/showexceptions.rb:24:in `call'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:195:in `context'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:190:in `call'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/lint.rb:48:in `_call'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/lint.rb:36:in `call'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/showexceptions.rb:24:in `call'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/commonlogger.rb:20:in `call'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/chunked.rb:41:in `call'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/content_length.rb:14:in `call'
/Users/artem/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.0/lib/rack/handler/webrick.rb:59:in `service'
/Users/artem/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/artem/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/artem/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
127.0.0.1 - - [26/Nov/2011 13:01:28] "GET / HTTP/1.1" 500 81223 0.0653