Simon Rees wrote:
> Hello
> 
> I'm using CGI::Application::Dispatch under mod_perl 2 to display all the 
> pages 
> on a site I'm working on and have had problems getting it to play nicely with 
> path_info as reported by Apache.
> 
> What I would like to happen is:
> Request: http://example.com/foo/bar
> Calls: run mode bar in module Foo
> 
> When I set this up as a mod perl handler it doesn't work as expected as the 
> first directory in the path is removed. In the above example I get "/bar" in 
> path_info. I realise this is an Apache issue that it may not be possible to 
> solve, but for information here is my minimal config:

It is an apache issue. path_info has some issues in that it can change depending
on the real directory structure underneath. If you have DocumentRoot/foo then a
url of "/foo/bar" will have a path_info of "/bar". That's just how apache works.
Don't ask me why.

To get around this I usually setup a <Location /app> and then use that for my
application (and thus dispatch) and things like /images, /js, /css, etc for
other stuff. But the key is to not have the URL match up with the actual
directory tree.

> I assume that because the document root dir does exist the first dir in the 
> request uri is satisfied and so only subsequent dirs are set in PATH_INFO.

It's not just the first dir. It's any dirs that match the document tree.

> What it seems I actually want to do is obtain the request uri and pass that 
> to 
> CA::Dispatch. 

That sounds like a reasonable way to do it as long as you know that's how your
site needs to behave.

> To solve this in the short term I've subclassed CA::Dispatch 
> and overridden the handler() method. The subclass method is exactly the same 
> except for:
> $ENV{PATH_INFO} = $r->uri();          # was $r->path_info()
> 
> My questions are:
> Am I missing something for my apache config that would cause PATH_INFO to 
> include the complete uri path?
> Is my technique for subclassing CA::Dispatch and using uri rather than 
> path_info reasonable? 

Yes, it is reasonable.

> Are there better ways I could do this?

Probably nothing you could do by yourself. But Dispatch should probably make
this kind of thing easier. You're not the first to have this problem and it
makes sense to allow subclasses to extend how the URL is determined. So, I'm
thinking that adding a method named "get_url_path" (or something similar) that
just returns $ENV{PATH_INFO} by default. But that you could override to get the
url if you want.

-- 
Michael Peters
Developer
Plus Three, LP


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to