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);