Re: Custom Error Handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi André,

On Tue 16 Jun 2009, André Warnier wrote:
> Alan Wilson wrote:
> > Thanks - that makes sense, using a test along the lines of
> >
> > print "Content-Type: text/html\n";
> > print "Status: 302 Moved\nLocation:
> > http://www.mydomain.com/test.cgi\n\n";; print "\n";
> >
> > Seems to do what I want.
>
> That is strange, and I am surprised it works (but I don't know
> everything). The way you are doing it above, you are still sending an
> (implicit) HTTP response code of 200 (OK), and then sending a HTTP
> header "Status:", which is normally not how these things work.
>
>
> Assuming you are not using CGI.pm, I would have written it as :
>
> print "302 Moved\n";
> print "Location: http://www.mydomain.com/test.cgi\n\n";;
>
>
> In perl, and using the CGI module, you would have something like :
>
> ...
> use CGI qw/:standard/;
> ...
> my $q = new CGI;
> ...
> print $q->redirect(-uri=>'http://somewhere.else/in/movie/land',
>                 -status=>302);
> exit 1;
>
> See http://cpan.uwinnipeg.ca/htdocs/CGI.pm/CGI.html

$ perl -MCGI -e 'print CGI::redirect(-location=>"HUHU")'
Status: 302 Found
Location: HUHU

You see, even the CGI module prints the HTTP code as "Status: ..." 
header. This is consistent with the CGI "standard", see 
http://hoohoo.ncsa.illinois.edu/cgi/out.html

This document even explains what happens if there is a Location header 
but no Status header or a Status-200 header and the location is just a 
path not a complete URL. Such a response will not hit the client. 
Instead Apache will send the document referenced by the path.

Hence, Apache must parse the output of the CGI script.

You can avoid that using a so called non-parsed-header script. Then you 
can send the client whatever you want. Scan the documentation for more 
information.

Just my 2 Pfennige (die es nicht mehr gibt),
Torsten

-- 
Need professional mod_perl support?
Just hire me: torsten.foertsch@xxxxxxx

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux