Rack 获取基于会话的 cookie 时出错

发布于 2024-12-28 21:28:00 字数 1434 浏览 2 评论 0原文

我的网络应用程序使用的是 Rack 1.4.0、Sinatra v1.2.6、Thin v1.2.11、Ruby v1.9.2p180

导航到页面时我在日志中收到此错误:

TypeError - can't convert nil into String:
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/cookie.rb:152:in `hexdigest'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/cookie.rb:152:in `generate_hmac'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/cookie.rb:109:in `unpacked_cookie_data'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/cookie.rb:99:in `extract_session_id'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:43:in `load_session_id!'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:32:in `[]'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:262:in `current_session_id'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:268:in `session_exists?'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:107:in `exists?'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:122:in `load_for_read!'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:59:in `[]'
 /var/www/phrogz.net/routes/test.rb:8:in `logged_in?'

test.rb 第 8 行中的代码是:

session[ :foo ] == "BAR"

有关的任何建议升级/降级什么来解决这个问题?

My web app is using Rack 1.4.0, Sinatra v1.2.6, Thin v1.2.11, Ruby v1.9.2p180

Navigating to a page I get this error in the log:

TypeError - can't convert nil into String:
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/cookie.rb:152:in `hexdigest'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/cookie.rb:152:in `generate_hmac'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/cookie.rb:109:in `unpacked_cookie_data'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/cookie.rb:99:in `extract_session_id'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:43:in `load_session_id!'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:32:in `[]'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:262:in `current_session_id'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:268:in `session_exists?'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:107:in `exists?'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:122:in `load_for_read!'
 /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.0/lib/rack/session/abstract/id.rb:59:in `[]'
 /var/www/phrogz.net/routes/test.rb:8:in `logged_in?'

The code in test.rb line 8 is:

session[ :foo ] == "BAR"

Any suggestions on what to upgrade/downgrade to fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦幻的味道 2025-01-04 21:28:00

您似乎遇到了此问题。该修复已在 Rack 1.4.1 中进行,因此只需升级即可修复该问题。

Looks like you run into this issue. The fix is in Rack 1.4.1 so simply upgrading should fix it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文