From: ivan Date: Fri, 27 Sep 2002 05:31:15 +0000 (+0000) Subject: backport http_header from 1.5 X-Git-Tag: freeside_1_4_1beta4~29 X-Git-Url: http://git.freeside.biz/gitweb/?a=commitdiff_plain;h=94b61beb81ecf0e69115ffecd45d66d2c9bc0b78;hp=76f526368afbe13369635bcef58ad434b117fd00;p=freeside.git backport http_header from 1.5 --- 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.