Jeremy Hinegardner
2007-Apr-20 08:15 UTC
[Mongrel] order of registering uri''s matters for URIClassifier ?
Hi all,
I''m playing around with mongrel handlers and I came across a behaviour
that seems abnormal to me with regard to the Configurator#uri calls. It
appears that order matters.
For instance:
...
listener do
uri "/icons", :handler =>
DirHandler.new("/var/www/icons")
uri "/", :handler =>
DirHandler.new("/var/app/html")
uri "/", :handler => stats
end
...
with this sort of configuration, any URI that is alphabetically AFTER
"/icons" will be short circuited to a 404 error in mongrel.
The cause is basically :
@classifier.resolve("/junk") # => [nil,nil,nil]
Instead of :
["/junk", "/", [#<Mongrel::DirHandler>,
#<Mongrel::StatusHandler>]]
I''ve attached a unit test that shows this effect by calling the
URIClassifier directly. I''m not sure if this is a bug or a
misunderstanding on my part.
enjoy,
-jeremy
--
======================================================================= Jeremy
Hinegardner jeremy at hinegardner.org
-------------- next part --------------
require ''test/unit''
require ''rubygems''
require ''mongrel''
include Mongrel
class URIClassifierText < Test::Unit::TestCase
def test_classifier_order
u = URIClassifier.new
root = "/"
path = "/path"
u.register(path,1)
u.register(root,2)
["/before", "/way_past"].each do |uri|
sn,pi,h = u.resolve(uri)
assert_equal root,sn
assert_equal uri, pi
assert_equal 2,h
end
end
end
Zed A. Shaw
2007-Apr-21 15:46 UTC
[Mongrel] order of registering uri''s matters for URIClassifier ?
On Fri, 20 Apr 2007 02:15:02 -0600 Jeremy Hinegardner <jeremy at hinegardner.org> wrote:> Hi all, > > I''m playing around with mongrel handlers and I came across a behaviour > that seems abnormal to me with regard to the Configurator#uri calls. It > appears that order matters.I think this is a misunderstanding in how it works but let me double check.> I''ve attached a unit test that shows this effect by calling the > URIClassifier directly. I''m not sure if this is a bug or a > misunderstanding on my part.Thanks, this is perfect. I''ll take a look and see if it''s something. Oh, could you add this to the Mongrel bug tracker so that I''m constantly annoyed and have to fix it? :-) Thanks. -- Zed A. Shaw, MUDCRAP-CE Master Black Belt Sifu http://www.zedshaw.com/ http://www.awprofessional.com/title/0321483502 -- The Mongrel Book http://mongrel.rubyforge.org/
Jeremy Hinegardner
2007-Apr-21 17:04 UTC
[Mongrel] order of registering uri''s matters for URIClassifier ?
On Sat, Apr 21, 2007 at 11:46:53AM -0400, Zed A. Shaw wrote:> On Fri, 20 Apr 2007 02:15:02 -0600 > Jeremy Hinegardner <jeremy at hinegardner.org> wrote: > > > Hi all, > > > > I''m playing around with mongrel handlers and I came across a behaviour > > that seems abnormal to me with regard to the Configurator#uri calls. It > > appears that order matters. > > I think this is a misunderstanding in how it works but let me double > check.Thanks, I wasn''t sure if this was a misunderstanding on my part or an actual bug.> > I''ve attached a unit test that shows this effect by calling the > > URIClassifier directly. I''m not sure if this is a bug or a > > misunderstanding on my part. > > Thanks, this is perfect. I''ll take a look and see if it''s something. > > Oh, could you add this to the Mongrel bug tracker so that I''m > constantly annoyed and have to fix it? :-) Thanks.Its in the Mongrel bug tracker now. enjoy, -jeremy -- ======================================================================= Jeremy Hinegardner jeremy at hinegardner.org