You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by barries <ba...@slaysys.com> on 2001/07/05 15:49:28 UTC
Re: lookup_uri() returns 200 when 404 expected
On Thu, Jul 05, 2001 at 03:21:12PM +0100, Paul Sharpe wrote:
> Here's my handler...
>
> package Foo::Test;
> use strict;
> use warnings;
> use Apache::Constants qw(:common HTTP_OK);
>
> sub handler {
> my $r = shift;
> my $uri = 'foo.html';
> $r->content_type('text/plain');
> $r->send_http_header;
> $r->lookup_uri($uri);
Try: my $s = $r->lookup_uri($uri);
> $r->print("lookup_uri($uri) status = ",$r->status,"\n");
Try: $s->status
> }
>
> 1;
Re: lookup_uri() returns 200 when 404 expected
Posted by barries <ba...@slaysys.com>.
On Thu, Jul 05, 2001 at 04:57:13PM +0100, Paul Sharpe wrote:
>
> What would happen if the URI translated to something other than a file
> e.g. CGI?
You get the filename of the script.
- Barrie
Re: lookup_uri() returns 200 when 404 expected
Posted by Paul Sharpe <pa...@miraclefish.com>.
barries wrote:
>
> On Thu, Jul 05, 2001 at 04:03:00PM +0100, Paul Sharpe wrote:
> > barries wrote:
> > >
> > > On Thu, Jul 05, 2001 at 03:21:12PM +0100, Paul Sharpe wrote:
> > > > Here's my handler...
> > > >
> > > > package Foo::Test;
> > > > use strict;
> > > > use warnings;
> > > > use Apache::Constants qw(:common HTTP_OK);
> > > >
> > > > sub handler {
> > > > my $r = shift;
> > > > my $uri = 'foo.html';
> > > > $r->content_type('text/plain');
> > > > $r->send_http_header;
> > > > $r->lookup_uri($uri);
> > >
> > > Try: my $s = $r->lookup_uri($uri);
> > >
> > > > $r->print("lookup_uri($uri) status = ",$r->status,"\n");
> > >
> > > Try: $s->status
> > >
> > > > }
> > > >
> > > > 1;
> >
> > Still returns
> >
> > lookup_uri(foo.html) status = 200
>
> The lookup succeeds whether or not the file exists (though it will fail
> if the httpd.conf forbids access). This about the case of an
> all-virtual set of URIs where your mod_perl handler is simulating
> documents that don't exist. Results other than HTTP_OK will only occur
> if the URI->filename translation fails for some reason.
>
> In your case, I think you'd need to add
>
> my $c = $s->status ;
> $c = HTTP_NOT_FOUND if $c eq HTTP_OK && ! -e $s->filename ;
>
> and report the value of $c (also need to import HTTP_NOT_FOUND).
>
> HTH,
>
> Barrie
What would happen if the URI translated to something other than a file
e.g. CGI?
paul
--
Paul Sharpe Tel: +44 (20) 7407 5557
Miraclefish Ltd. Fax: +44 (20) 7378 8711
Studio 12 mailto:paul@miraclefish.com
37 Tanner Street http://www.miraclefish.com/
London SE1 3LF
UNITED KINGDOM
$r->finfo stability? [Was: lookup_uri() returns 200 when 404 expected]
Posted by barries <ba...@slaysys.com>.
On Fri, Jul 06, 2001 at 11:53:52AM +0100, Paul Sharpe wrote:
>
> Presumably $s->finfo would be more efficient?
Yes, if it's stable for your config. I've had coredumps with it in the
past some time and have since stayed away from it by habit. 'course
that was several versions of mod_perl and perl ago, so that's probably
stable now. I'd recommend staying away from it if you want to run on
older mod_perls (like you're distibuting a CPAN module), but it's
probably Ok for up to date configs.
Anyone else have good/bad experience w/ $r->finfo lately?
Also note that Apache will stat() it's way back up the path to the
document root in order to calculate path_info, so it can be better to do
the URI->filename mapping in Perl.
- Barrie
Re: lookup_uri() returns 200 when 404 expected
Posted by Paul Sharpe <pa...@miraclefish.com>.
barries wrote:
>
> On Thu, Jul 05, 2001 at 04:03:00PM +0100, Paul Sharpe wrote:
> > barries wrote:
> > >
> > > On Thu, Jul 05, 2001 at 03:21:12PM +0100, Paul Sharpe wrote:
> > > > Here's my handler...
> > > >
> > > > package Foo::Test;
> > > > use strict;
> > > > use warnings;
> > > > use Apache::Constants qw(:common HTTP_OK);
> > > >
> > > > sub handler {
> > > > my $r = shift;
> > > > my $uri = 'foo.html';
> > > > $r->content_type('text/plain');
> > > > $r->send_http_header;
> > > > $r->lookup_uri($uri);
> > >
> > > Try: my $s = $r->lookup_uri($uri);
> > >
> > > > $r->print("lookup_uri($uri) status = ",$r->status,"\n");
> > >
> > > Try: $s->status
> > >
> > > > }
> > > >
> > > > 1;
> >
> > Still returns
> >
> > lookup_uri(foo.html) status = 200
>
> The lookup succeeds whether or not the file exists (though it will fail
> if the httpd.conf forbids access). This about the case of an
> all-virtual set of URIs where your mod_perl handler is simulating
> documents that don't exist. Results other than HTTP_OK will only occur
> if the URI->filename translation fails for some reason.
>
> In your case, I think you'd need to add
>
> my $c = $s->status ;
> $c = HTTP_NOT_FOUND if $c eq HTTP_OK && ! -e $s->filename ;
>
> and report the value of $c (also need to import HTTP_NOT_FOUND).
>
Presumably $s->finfo would be more efficient?
paul
> HTH,
>
> Barrie
--
Paul Sharpe Tel: +44 (20) 7407 5557
Miraclefish Ltd. Fax: +44 (20) 7378 8711
Studio 12 mailto:paul@miraclefish.com
37 Tanner Street http://www.miraclefish.com/
London SE1 3LF
UNITED KINGDOM
Re: lookup_uri() returns 200 when 404 expected
Posted by barries <ba...@slaysys.com>.
On Thu, Jul 05, 2001 at 04:03:00PM +0100, Paul Sharpe wrote:
> barries wrote:
> >
> > On Thu, Jul 05, 2001 at 03:21:12PM +0100, Paul Sharpe wrote:
> > > Here's my handler...
> > >
> > > package Foo::Test;
> > > use strict;
> > > use warnings;
> > > use Apache::Constants qw(:common HTTP_OK);
> > >
> > > sub handler {
> > > my $r = shift;
> > > my $uri = 'foo.html';
> > > $r->content_type('text/plain');
> > > $r->send_http_header;
> > > $r->lookup_uri($uri);
> >
> > Try: my $s = $r->lookup_uri($uri);
> >
> > > $r->print("lookup_uri($uri) status = ",$r->status,"\n");
> >
> > Try: $s->status
> >
> > > }
> > >
> > > 1;
>
> Still returns
>
> lookup_uri(foo.html) status = 200
The lookup succeeds whether or not the file exists (though it will fail
if the httpd.conf forbids access). This about the case of an
all-virtual set of URIs where your mod_perl handler is simulating
documents that don't exist. Results other than HTTP_OK will only occur
if the URI->filename translation fails for some reason.
In your case, I think you'd need to add
my $c = $s->status ;
$c = HTTP_NOT_FOUND if $c eq HTTP_OK && ! -e $s->filename ;
and report the value of $c (also need to import HTTP_NOT_FOUND).
HTH,
Barrie
Re: lookup_uri() returns 200 when 404 expected
Posted by Paul Sharpe <pa...@miraclefish.com>.
barries wrote:
>
> On Thu, Jul 05, 2001 at 03:21:12PM +0100, Paul Sharpe wrote:
> > Here's my handler...
> >
> > package Foo::Test;
> > use strict;
> > use warnings;
> > use Apache::Constants qw(:common HTTP_OK);
> >
> > sub handler {
> > my $r = shift;
> > my $uri = 'foo.html';
> > $r->content_type('text/plain');
> > $r->send_http_header;
> > $r->lookup_uri($uri);
>
> Try: my $s = $r->lookup_uri($uri);
>
> > $r->print("lookup_uri($uri) status = ",$r->status,"\n");
>
> Try: $s->status
>
> > }
> >
> > 1;
Still returns
lookup_uri(foo.html) status = 200
paul
--
Paul Sharpe Tel: +44 (20) 7407 5557
Miraclefish Ltd. Fax: +44 (20) 7378 8711
Studio 12 mailto:paul@miraclefish.com
37 Tanner Street http://www.miraclefish.com/
London SE1 3LF
UNITED KINGDOM