From 94b61beb81ecf0e69115ffecd45d66d2c9bc0b78 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 27 Sep 2002 05:31:15 +0000 Subject: [PATCH] backport http_header from 1.5 --- FS/FS/CGI.pm | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/FS/FS/CGI.pm b/FS/FS/CGI.pm index e44ebcc0a..d69aad2fc 100644 --- a/FS/FS/CGI.pm +++ b/FS/FS/CGI.pm @@ -10,7 +10,7 @@ use FS::UID; @ISA = qw(Exporter); @EXPORT_OK = qw(header menubar idiot eidiot popurl table itable ntable - small_custview myexit); + small_custview myexit http_header); =head1 NAME @@ -68,6 +68,38 @@ END $x; } +=item http_header + +Sets an http header. + +=cut + +sub http_header { + my ( $header, $value ) = @_; + if (exists $ENV{MOD_PERL}) { + if ( defined $main::Response + && $main::Response->isa('Apache::ASP::Response') ) { #Apache::ASP + if ( $header =~ /^Content-Type$/ ) { + $main::Response->{ContentType} = $value; + } else { + $main::Response->AddHeader( $header => $value ); + } + } elsif ( defined $HTML::Mason::Commands::r ) { #Mason + ## is this the correct pacakge for $r ??? for 1.0x and 1.1x ? + if ( $header =~ /^Content-Type$/ ) { + $HTML::Mason::Commands::r->content_type($value); + } else { + $HTML::Mason::Commands::r->header_out( $header => $value ); + } + } else { + die "http_header called in unknown environment"; + } + } else { + die "http_header called not running under mod_perl"; + } + +} + =item menubar ITEM, URL, ... Returns an HTML menubar. -- 2.11.0