request.env.to_json fails
Reported by Greg Hazel | September 27th, 2009 @ 06:54 PM | in Future
This might not be the right place to file this bug, but using Thin I get an error:
request.env.to_json produces:
IOError (not opened for reading):
/vendor/rails/activesupport/lib/active_support/json/encoders/enumerable.rb:10:in `each'
/vendor/rails/activesupport/lib/active_support/json/encoders/enumerable.rb:10:in `map'
/vendor/rails/activesupport/lib/active_support/json/encoders/enumerable.rb:10:in `to_json'
Upon inspection, the troublesome key seems to be: "rack.errors" => #<IO:0x3146ad8>
Is that really necessary?
Comments and changes to this ticket
-
macournoyer September 28th, 2009 @ 10:18 AM
- State changed from new to invalid
rack.errors is set to STDERR. It's like doing STDERR.to_json
I guess you could set rack.errors to nil before doing that or create another hash w/ only the keys you want, or do something like:
request.env.keys.sort.inject({}) {|e,(k,v)| e[k] = v.to_s }.to_json
-
Greg Hazel September 28th, 2009 @ 11:03 AM
Isn't there a better place for than sort of variable than env? It would be neat it the environment was entirely made of strings, like a shell environment.
-
macournoyer September 28th, 2009 @ 12:09 PM
That's the Rack environment, nothing to do w/ shell env. Rack env is the
only way to pass data around from request to response across apps and
middlewares. Restricting to strings would be uselessly restrictive and
degrade performance. -
Greg Hazel September 28th, 2009 @ 12:20 PM
It is very related to the CGI environment variables, which have classically been strings since they were passed by the shell. The Rack parameters which are not strings have been conflated with the CGI parameters. This makes the hash difficult to serialize, when the rack variables should not be passed through a CGI-like interface.
There are many options for improving this situation:
1) Have "request.rack" separate from "request.env"
2) Have "request.env['rack']" contain a hash of all the rack-related variables
3) Have "request.env['cgi']" contain all the CGI-like environment variables
-
kbrow8249 July 14th, 2022 @ 02:29 PM
I almost completed my dissertation on time, everything was going smoothly and according to the plan but then
I had major personal problems and couldn’t finish editing. I sent my papers to
essay helper online service and they completed it splendidly.
These guys are rescued me and i will recommend this company to all my colleagues! -
QyriMarry July 15th, 2022 @ 06:32 AM
casino online! Dieses Angebot gilt nur für die erste Einzahlung. Die Mindesteinzahlung beträgt 10€.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป