Date: Tuesday February 25, 2003 @ 14:21
Author: matt
Update of /home/cvs/AxKit-XSP-WebUtils
In directory ted.sergeant.org:/tmp/cvs-serv7440
Modified Files:
WebUtils.pm
Log Message:
Log: Allow redirect to use the Refresh header instead of Location
Submitted by:
Reviewed by:
PR:
Index: WebUtils.pm
===================================================================
RCS file: /home/cvs/AxKit-XSP-WebUtils/WebUtils.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -b -u -r1.5 -r1.6
--- WebUtils.pm 2002/06/20 10:22:44 1.5
+++ WebUtils.pm 2003/02/25 14:21:59 1.6
@@ -1,4 +1,4 @@
-# $Id: WebUtils.pm,v 1.5 2002/06/20 10:22:44 matt Exp $
+# $Id: WebUtils.pm,v 1.6 2003/02/25 14:21:59 matt Exp $
# Original Code and comments from Steve Willer.
@@ -25,7 +25,7 @@
'request_uri()',
'request_host()',
'server_root()',
- 'redirect($uri;$host,$secure)',
+ 'redirect($uri;$host,$secure,$use_refresh)',
'url_encode($string)',
'url_decode($string)',
'header($name;$value)',
@@ -74,10 +74,12 @@
}
sub redirect ($;$$) {
- my ($uri, $host, $secure) = @_;
+ my ($uri, $host, $secure, $use_refresh) = @_;
if (lc($secure) eq 'yes') { $secure = 1 }
- if (lc($secure) eq 'no') { $secure = 0 }
+ elsif (lc($secure) eq 'no') { $secure = 0 }
+ if (lc($use_refresh) eq 'yes') { $use_refresh = 1 }
+ elsif (lc($use_refresh) eq 'no') { $use_refresh = 0 }
my $myhost = $host;
@@ -111,12 +113,26 @@
my $scheme = 'http';
$scheme = 'https' if $secure; # Hmm, might break if $port was set above...
+ if ($use_refresh) {
+ $Request->header_out("Refresh" => "0; url=${scheme}://${myhost}${uri}");
+ $Request->content_type("text/html");
+ $Request->status(200);
+ }
+ else {
$Request->header_out("Location" => "${scheme}://${myhost}${uri}");
$Request->status(302);
}
+ }
else {
- $Request->header_out("Location" => "$uri");
+ if ($use_refresh) {
+ $Request->header_out("Refresh" => "0; url=$uri");
+ $Request->content_type("text/html");
+ $Request->status(200);
+ }
+ else {
+ $Request->header_out("Location" => $uri);
$Request->status(302);
+ }
}
$Request->send_http_header;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]