in reply to Redirection to one cgi page from another is not working
I'm not sure what your overall use of this is. But it might be worth looking at the pertinent RFC's HTTP status code(s). As I can never remember them, I took the liberty of creating a quick "cheat sheet". If your interested, here's the link to the pertinent section. I only mention it, because it is relevant to pass the correct status. ie;
You can also deliver CONTENT-TYPE on a conditional basis#!/usr/bin/perl -w use strict; print "Status: 301 Moved Permanently\n"; print "Location: http://COMPLETE/URI\n\n"; # complete URI (not relative) is important for proxies/squid/and HTTP- +1.0 # Sending STATUS _first_ also matters exit;
Wouldn't it be fun to boast of being XHTML compliant, even when your not?#!/usr/bin/perl -Tw #accepts application/xhtml? if ($ENV{'HTTP_ACCEPT'} =~ /application\/xhtml\+xml/) { print "content-type:application/xhtml+xml; charset=utf-8\n\n"; } #no? then text/html they get else { print "content-type:text/html; charset=utf-8\n\n"; }
Note the different stylesheet delivered, based on UA (User Agent).if ($ENV{'HTTP_USER_AGENT'} =~ /W3C\_CSS\_Validator\_JFouffa/) { print "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +; print "<?xml-stylesheet href=\"w3c.css\" type=\"text\/css\" media= +\"screen, projection, print\" ?>\n"; print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0// +EN\" \"http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd\"> <html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n"; print "<head>\n"; my $server = $ENV{SERVER_NAME}; print " <title>"; print $server; print "</title>\n"; print " <meta http-equiv=\"content-type\" content=\"application\/xh +tml+xml; charset=utf-8\" />\n"; } else { print "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +; print "<?xml-stylesheet href=\"css3.css\" type=\"text\/css\" media +=\"screen, projection, print\" ?>\n"; print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0// +EN\" \"http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd\"> <html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n"; print "<head>\n"; my $server = $ENV{SERVER_NAME}; print " <title>"; print $server; print "</title>\n"; print " <meta http-equiv=\"content-type\" content=\"application\/xh +tml+xml; charset=utf-8\" />\n"; print " <link rel=\"stylesheet\" type=\"text/css\" href=\"css3.css\ +" media=\"screen, projection, print\" />\n"; }
FWIW INMHO CGI (cgi.pm) is evil, and should be avoided at all cost. The simplicity of it's use, and making your code appear clean, and tidy. Make it's usage very tempting. But it is my experience, that it abstracts one so far away from what they're doing, that over time, one can easily create code that encounters issues. Making it an unnecessary job to diagnose, and correct. In short; if you don't have to think about something long enough. You'll forget it -- hope that made sense to more than just me. :)
Best wishes.
Chris
#!/usr/bin/perl -Tw use Perl::Always or die; my $perl_version = (5.12.5); print $perl_version;
|
|---|