summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2002-09-27 05:31:15 +0000
committerivan <ivan>2002-09-27 05:31:15 +0000
commit94b61beb81ecf0e69115ffecd45d66d2c9bc0b78 (patch)
tree5e21f82077e6abbf8525a821fd03b1eab14e8818
parent76f526368afbe13369635bcef58ad434b117fd00 (diff)
backport http_header from 1.5
-rw-r--r--FS/FS/CGI.pm34
1 files changed, 33 insertions, 1 deletions
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.