Re: $r-path_info question

2002-07-23 Thread darren chamberlain

* simran [EMAIL PROTECTED] [2002-07-23 05:11]:
 However: if i create an 'auto' directory in my document root
 (something that was not there before)
 

[-- snip --]

 Is this is feature or a bug, does path_info not check the 'Location' it
 matced the handler to or is it meant to look at the directory structure?

This is how Apache handles path_info: it is the extra stuff after
the translation handler has found a directory and filename.  It starts
at the left, and walks towards the right, until it finds the last
component that is a directory, and then the next piece is the file (no
existance check is done at this point).  The rest of it is path_info.

For example:

A request for /foo/bar/baz/quux, with a document root of /document/root
(assuming no Alias directives, that complicates things slightly), and
assuming that /document/root/foo is the last *directory* in the path
that exists, Apache does this:

  1. look for /document - yep
  2. look for /document/root - yep
  3. look for /document/root/foo - yep
  4. look for /document/root/foo/bar - nope

So /document/root/foo/bar is r-filename, and /baz/quux is path_info.

To reiterate: this is not a mod_perl thing (bug/whatever) but an Apache
one.

(darren)

-- 
An operating system is just a name you give the features you left
out of your editor.
-- Per Abrahamsen in comp.emacs



Re: $r-path_info question

2000-06-27 Thread David Kenzik

  Drew Taylor said...

  Hi all,

Hi.

  I currently am using 
  
  my $filename = (split /\//, $r-path_info)[1];
  
  but it seems like such a hack. What is the "suggested" way to get the
  "A1234567.jpg" part of the above URL?

Since Apache sets path_info by scanning the physical filesystem, and since
you are overcoming legacy calls to a script inside cgi-bin, your solution is
probably just fine.

I had a similar issue in the past:

http://forum.swarthmore.edu/epigone/modperl/smumbabax

As Doug mentions in that thread, $r-location might be of some assistance.

Hope this helps.

-- 
David S. Kenzik
[EMAIL PROTECTED] - http://kenzik.com



Re: $r-path_info question

2000-06-27 Thread Drew Taylor

David Kenzik wrote:
 
   Drew Taylor said...
  
   I currently am using
  
   my $filename = (split /\//, $r-path_info)[1];
  
   but it seems like such a hack. What is the "suggested" way to get the
   "A1234567.jpg" part of the above URL?
 
 Since Apache sets path_info by scanning the physical filesystem, and since
 you are overcoming legacy calls to a script inside cgi-bin, your solution is
 probably just fine.
 
 I had a similar issue in the past:
 
 http://forum.swarthmore.edu/epigone/modperl/smumbabax
 
 As Doug mentions in that thread, $r-location might be of some assistance.
That was an interesting thread. However, I think Eric found the easiest
solution for me. This handler is very simple and if the requested file
does not pass -e, it just returns NOT_FOUND. So I guess I'll stick with
my original thinking for now.

Thanks.

-- 
Drew Taylor
Vialogix Communications, Inc.
501 N. College Street
Charlotte, NC 28202
704 370 0550
http://www.vialogix.com/



Re: $r-path_info question

2000-06-27 Thread Eric Cholet

 Hi all,
 
 I am using $r-path_info in an Apache handler. The handler is set via a
 Location directive:
 
 Location /cgi-bin/detail.pl # Overcoming Legacy code :-)
 SetHandler perl-script
 PerlHandler eLogix::Images::Detail
 /Location
 
 And is called like "/cgi-bin/detail.pl/A1234567.jpg". My question is
 this: Since there is no physical filename which corresponds to the URL,
 what does path_info contain? In the eagle book on page 135, when
 path_info is first discussed, the example uses
 $r-lookup_uri($path_info) to get the filename, which in this example is
 a purely virtual tree.

$r-path_info contains what's left of the URI after it's been mapped
to a (virtual) file, in your case /A1234567.jpg

 I currently am using 
 
 my $filename = (split /\//, $r-path_info)[1];

or you could have used
  (my $filename = $r-path_info) =~ s!^/!!;

 but it seems like such a hack. What is the "suggested" way to get the
 "A1234567.jpg" part of the above URL?

Since you have no trailing slash in your Location directive,
you get a leading / in path_info. What would be the filename if the
request URI was /cgi-bin/detail.pl/foo/bar.jpg ? In that case 
path_info will be '/foo/bar.jpg'. Maybe what you really want
is 
  my $filename = (split /\//, $r-path_info)[-1];

whatever... it's completely up to the application to define the
semantics of path_info.

 -- 
 Drew Taylor

--
Eric