[Nitro] request mangling
James Britt
james_b at neurogami.com
Wed Nov 9 17:41:10 EST 2005
akonsu wrote:
> I recall I have seen code in either nitro or the related gems where it
> adds "/index.html". just grep for "index.html". i think it has
> something to do with nitro trying to decide which file to serve if
> none is given.
>
Indeed. My copy of webrick.rb, from Nitro 0.24.0, has this as line 161
# Try to rewrite the path to a filename.
def rewrite(req)
if req.path == '/'
req.instance_variable_set(:@path_info, '/index.html')
elsif req.path =~ /^([^.]+)$/
req.instance_variable_set(:@path_info, "#{$1}/index.html")
end
end
# Rewrite back to the original path.
def unrewrite(req)
if req.path == '/'
req.instance_variable_set(:@path_info, '/')
elsif req.path =~ /^([^.]+).html$/
req.instance_variable_set(:@path_info, $1)
end
end
end
This strikes me a Bad Thing, something that should be handled at the
application level. Compulsory rewrites leave a bad taste in my mouth.
--
http://www.ruby-doc.org - Ruby Help & Documentation
http://www.artima.com/rubycs/ - Ruby Code & Style: Writers wanted
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
http://www.30secondrule.com - Building Better Tools
More information about the Nitro-general
mailing list