Added WebGUI::HTTP::setNoHeader

This commit is contained in:
Len Kranendonk 2004-08-13 09:37:03 +00:00
parent afbd12779b
commit cb1b60d352
3 changed files with 25 additions and 3 deletions

View file

@ -104,7 +104,7 @@ sub generate {
# Disable printing of HTTP Header if requested. # Disable printing of HTTP Header if requested.
if($self->get('noHttpHeader')) { if($self->get('noHttpHeader')) {
$session{page}{noHttpHeader} = 1; WebGUI::HTTP::setNoHeader(1);
} }
# Set alternate Site URL # Set alternate Site URL

View file

@ -33,7 +33,8 @@ use WebGUI::HTTP;
$header = WebGUI::HTTP::getHeader(); $header = WebGUI::HTTP::getHeader();
WebGUI::HTTP::setRedirect($url); WebGUI::HTTP::setRedirect($url);
WebGUI::HTTP::setCookie($name,$value); WebGUI::HTTP::setCookie($name,$value);
WebGUI::HTTP::setNoHeader($bool);
=head1 METHODS =head1 METHODS
These subroutines are available from this package: These subroutines are available from this package:
@ -51,7 +52,7 @@ Generates an HTTP header.
=cut =cut
sub getHeader { sub getHeader {
return undef if ($session{page}{noHttpHeader}); return undef if ($session{http}{noHeader});
my $header; my $header;
unless (exists $session{http}{location}) { unless (exists $session{http}{location}) {
unless ($session{http}{charset}) { unless ($session{http}{charset}) {
@ -195,6 +196,26 @@ sub setMimeType {
$session{http}{mimetype} = shift; $session{http}{mimetype} = shift;
} }
#-------------------------------------------------------------------
=head2 setNoHeader ( boolean )
Disables the printing of a HTTP header. Useful in situations when content is not
returned to a browser (export to disk for example).
=over
=item boolean
Any value other than 0 will disable header printing.
=back
=cut
sub setNoHeader {
$session{http}{noHeader} = shift;
}
#------------------------------------------------------------------- #-------------------------------------------------------------------

View file

@ -234,6 +234,7 @@ sub process {
unless (-f $file->getPath) { unless (-f $file->getPath) {
WebGUI::ErrorHandler::warn("Could not create file ".$file->getPath."\nTemplate file caching is disabled"); WebGUI::ErrorHandler::warn("Could not create file ".$file->getPath."\nTemplate file caching is disabled");
$params{scalarref} = \$template; $params{scalarref} = \$template;
delete $params{filename};
} }
} }
return _execute(\%params,$vars); return _execute(\%params,$vars);