Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

request.env.to_json fails

#114

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?

Reported by Greg Hazel · September 27th, 2009 @ 06:54 PM

State: invalid
Milestone: Future
Assigned to: macournoyer macournoyer

Activity

  1. macournoyer
    macournoyer
    • 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
    

    September 28th, 2009 @ 10:18 AM

  2. Greg Hazel
    Greg Hazel

    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.

    September 28th, 2009 @ 11:03 AM

  3. macournoyer
    macournoyer

    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.

    September 28th, 2009 @ 12:09 PM

  4. Greg Hazel
    Greg Hazel

    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

    September 28th, 2009 @ 12:20 PM

  5. kbrow8249
    kbrow8249

    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!

    July 14th, 2022 @ 02:29 PM

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.