Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Redirection to one cgi page from another is not working

by taint (Chaplain)
on Nov 11, 2013 at 22:19 UTC ( [id://1062066]=note: print w/replies, xml ) Need Help??


in reply to Redirection to one cgi page from another is not working

Greetings, nadarajan_v.

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;

#!/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;
You can also deliver CONTENT-TYPE on a conditional basis
#!/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"; }
Wouldn't it be fun to boast of being XHTML compliant, even when your not?
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"; }
Note the different stylesheet delivered, based on UA (User Agent).

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;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1062066]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2024-04-16 16:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found