K
Ken Brush
Hi All,
I couldn't find a bug tracker for ruby, to see if this was known or
not. Anyhow, there is a problem with cgi/session. It'll convert a
value of a hash stored in the session to an array, I think on close.
Here's the test case I'm using:
--- Start ruby code ---
#!/usr/bin/ruby
# Test case for cgi session
require 'cgi'
require 'cgi/session'
cgi =3D CGI.new("html4")
begin
session =3D CGI::Session.new(cgi, 'new_session' =3D> false)
rescue ArgumentError =20
session =3D CGI::Session.new(cgi, 'new_session' =3D> true)
end
session['cart'] ||=3D Hash.new(0);
session['cart'][cgi.params["id"]] +=3D 1
out =3D "#{cgi.params["id"]} -- #{session['cart'][cgi.params["id"]]}"
print cgi.header
print cgi.out() { out }
session.close
-- End of ruby code ---
When accessed with something like:=20
http://localhost/~kbrush/add.rb?id=3Dfoo
it'll print 'foo -- 1'
then access it again and you'll get an 'Internal Error'
This is the error in error.log:
[Mon Aug 15 09:25:27 2005] [error] mod_ruby: error in ruby
[Mon Aug 15 09:25:27 2005] [error] mod_ruby:
/home/kbrush/public_html/add.rb:19:in `[]': cannot convert Array into
Integer (TypeError)
[Mon Aug 15 09:25:27 2005] [error] mod_ruby: from
/home/kbrush/public_html/add.rb:19
[Mon Aug 15 09:25:27 2005] [error] mod_ruby: from
/usr/lib/ruby/1.8/apache/ruby-run.rb:53:in `load'
[Mon Aug 15 09:25:27 2005] [error] mod_ruby: from
/usr/lib/ruby/1.8/apache/ruby-run.rb:53:in `handler'
[Mon Aug 15 09:25:28 2005] [error] [client 127.0.0.1] File does not
exist: /var/www/favicon.ico
you get the same error if you use mod_ruby or not.
-Ken
I couldn't find a bug tracker for ruby, to see if this was known or
not. Anyhow, there is a problem with cgi/session. It'll convert a
value of a hash stored in the session to an array, I think on close.
Here's the test case I'm using:
--- Start ruby code ---
#!/usr/bin/ruby
# Test case for cgi session
require 'cgi'
require 'cgi/session'
cgi =3D CGI.new("html4")
begin
session =3D CGI::Session.new(cgi, 'new_session' =3D> false)
rescue ArgumentError =20
session =3D CGI::Session.new(cgi, 'new_session' =3D> true)
end
session['cart'] ||=3D Hash.new(0);
session['cart'][cgi.params["id"]] +=3D 1
out =3D "#{cgi.params["id"]} -- #{session['cart'][cgi.params["id"]]}"
print cgi.header
print cgi.out() { out }
session.close
-- End of ruby code ---
When accessed with something like:=20
http://localhost/~kbrush/add.rb?id=3Dfoo
it'll print 'foo -- 1'
then access it again and you'll get an 'Internal Error'
This is the error in error.log:
[Mon Aug 15 09:25:27 2005] [error] mod_ruby: error in ruby
[Mon Aug 15 09:25:27 2005] [error] mod_ruby:
/home/kbrush/public_html/add.rb:19:in `[]': cannot convert Array into
Integer (TypeError)
[Mon Aug 15 09:25:27 2005] [error] mod_ruby: from
/home/kbrush/public_html/add.rb:19
[Mon Aug 15 09:25:27 2005] [error] mod_ruby: from
/usr/lib/ruby/1.8/apache/ruby-run.rb:53:in `load'
[Mon Aug 15 09:25:27 2005] [error] mod_ruby: from
/usr/lib/ruby/1.8/apache/ruby-run.rb:53:in `handler'
[Mon Aug 15 09:25:28 2005] [error] [client 127.0.0.1] File does not
exist: /var/www/favicon.ico
you get the same error if you use mod_ruby or not.
-Ken