Hope this is better format
How does one employ CGI redirect in such a way that it will work within the fabric of other scripts?
While the below code functions correctly, from a practical standpoint it is severely restricted in it's usefulness.
Why is that you ask?
- Consider the application objective of presenting a plain text/html greeting like 'Hello World' and then offering the client the option of downloading a file (said download script requires an HTTP application header of the type application/x-octet-stream).
- Try and mix different HTTP headers and you get nada, neither the redirect nor the download called by the redirect will work!
- Perlmonks recommended using CGI re-direct. OK, below is a redirect script that calls my download script and it works fine....so long as nothing and i mean absolutely nothing writes out any plain text html (no 'Hello World') to the client browser!
In order to offer the client a greeting (and of course a choice if s/he wants do perform a download), we need to allow plain text/html to go to STDOUT versus the present, but very limited standalone functionality supporting no user context at all. I welcome your ideas please
#! /usr/bin/perl -wT
use strict;
use CGI qw(:standard escape escapeHTML);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser); #all diagnostic t
+o browser
my $url = 'http://www.gmacfadden.com/cgi-bin/WorkControl/Home/download
+_file_from_file.cgi'; # any absolute URL
print redirect(-location => $url);
exit (0);
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.