From: Tim Carey-Smith <g@spork.in>
To: rack-devel@googlegroups.com
Subject: Re: Why env.object_id is different in each middleware?
Date: Mon, 4 Jan 2010 13:50:22 +1300 [thread overview]
Message-ID: <A361F143-9409-4464-8DFA-33131C5E76D7@spork.in> (raw)
In-Reply-To: <200912100015.17445.ibc@aliax.net>
On 10/12/2009, at 12:15 PM, Iñaki Baz Castillo wrote:
> El Miércoles, 9 de Diciembre de 2009, Iñaki Baz Castillo escribió:
>> Since env is a hash I cannot understand why its object_id changes.
>> Any
>> explanation for it?
>> This explains that when I change env[XXX] into my final appplication
>> MyApp.handle_request the change doesn't exist after calling
>> resp = @app.call(env)
>> in the first middleware.
>
> If I add a env["LALA"] in the first middleware then it's visible for
> following
> middlewares.
> However if I add env["LOLO"] in the second middleware this is not
> visible for
> first middleware after calling "@app.call(env)".
>
> Is it the expected behavior?
>
> Thanks.
Hi there,
I've hit this before. This is because you are using Rack::URLMap (via
Builder#map).
The inner app is called with a new env hash.
> diff --git a/lib/rack/urlmap.rb b/lib/rack/urlmap.rb
> index b699d35..3374535 100644
> --- a/lib/rack/urlmap.rb
> +++ b/lib/rack/urlmap.rb
> @@ -45,7 +45,7 @@ module Rack
> next unless rest.empty? || rest[0] == ?/
>
> return app.call(
> - env.merge(
> + env.merge!(
> 'SCRIPT_NAME' => (script_name + location),
> 'PATH_INFO' => rest))
> }
Is this patch useful?
Is it useful to assume that a request will only have a single env hash?
Will it make Rack::Cascade and friends behave incorrectly?
Should URLMap revert the change in an ensure to allow subsequent
requests to function?
Hope this explains the behaviour,
Tim
next prev parent reply other threads:[~2010-01-04 0:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-09 22:59 Why env.object_id is different in each middleware? Iñaki Baz Castillo
2009-12-09 23:15 ` Iñaki Baz Castillo
2010-01-04 0:50 ` Tim Carey-Smith [this message]
2010-01-04 0:58 ` Iñaki Baz Castillo
2010-01-04 19:44 ` Iñaki Baz Castillo
2010-01-05 20:57 ` Ryan Tomayko
2010-01-05 23:47 ` Iñaki Baz Castillo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://groups.google.com/group/rack-devel
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=A361F143-9409-4464-8DFA-33131C5E76D7@spork.in \
--to=rack-devel@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).