From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.140.141.15 with SMTP id o15cs1231559rvd; Sun, 3 Jan 2010 16:50:31 -0800 (PST) Received: from mr.google.com ([10.101.166.27]) by 10.101.166.27 with SMTP id t27mr18612231ano.58.1262566230290 (num_hops = 1); Sun, 03 Jan 2010 16:50:30 -0800 (PST) Received: by 10.101.166.27 with SMTP id t27mr2822524ano.58.1262566228906; Sun, 03 Jan 2010 16:50:28 -0800 (PST) X-BeenThere: rack-devel@googlegroups.com Received: by 10.231.123.103 with SMTP id o39ls252677ibr.3.p; Sun, 03 Jan 2010 16:50:28 -0800 (PST) Received: by 10.231.120.209 with SMTP id e17mr2510896ibr.21.1262566227702; Sun, 03 Jan 2010 16:50:27 -0800 (PST) Received: by 10.231.120.209 with SMTP id e17mr2510895ibr.21.1262566227677; Sun, 03 Jan 2010 16:50:27 -0800 (PST) Return-Path: Received: from plastic.spork.in (plastic.spork.in [67.207.130.88]) by gmr-mx.google.com with ESMTP id 24si2372865iwn.11.2010.01.03.16.50.27; Sun, 03 Jan 2010 16:50:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of g@spork.in designates 67.207.130.88 as permitted sender) client-ip=67.207.130.88; Received: from [192.168.1.104] (121-72-240-112.cable.telstraclear.net [121.72.240.112]) (Authenticated sender: tim@halorgium.net) by plastic.spork.in (Postfix) with ESMTPSA id 87BBA4235D for ; Mon, 4 Jan 2010 13:50:25 +1300 (NZDT) Message-Id: From: Tim Carey-Smith To: rack-devel@googlegroups.com In-Reply-To: <200912100015.17445.ibc@aliax.net> Mime-Version: 1.0 (Apple Message framework v936) Subject: Re: Why env.object_id is different in each middleware? Date: Mon, 4 Jan 2010 13:50:22 +1300 References: <200912092359.08240.ibc@aliax.net> <200912100015.17445.ibc@aliax.net> X-Mailer: Apple Mail (2.936) X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of g@spork.in designates 67.207.130.88 as permitted sender) smtp.mail=g@spork.in X-Original-Sender: g@spork.in Reply-To: rack-devel@googlegroups.com Precedence: list Mailing-list: list rack-devel@googlegroups.com; contact rack-devel+owners@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: X-Thread-Url: http://groups.google.com/group/rack-devel/t/5d93266373a372ea X-Message-Url: http://groups.google.com/group/rack-devel/msg/2a85194558fab674 Sender: rack-devel@googlegroups.com List-Unsubscribe: , List-Subscribe: , Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable On 10/12/2009, at 12:15 PM, I=F1aki Baz Castillo wrote: > El Mi=E9rcoles, 9 de Diciembre de 2009, I=F1aki Baz Castillo escribi=F3:= >> Since env is a hash I cannot understand why its object_id changes. =20= >> 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 =3D @app.call(env) >> in the first middleware. > > If I add a env["LALA"] in the first middleware then it's visible for =20= > following > middlewares. > However if I add env["LOLO"] in the second middleware this is not =20 > 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 =20= 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] =3D=3D ?/ > > return app.call( > - env.merge( > + env.merge!( > 'SCRIPT_NAME' =3D> (script_name + location), > 'PATH_INFO' =3D> 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 =20 requests to function? Hope this explains the behaviour, Tim