From cb1b60d3529f79c8a5ca513683eab720015592b0 Mon Sep 17 00:00:00 2001 From: Len Kranendonk Date: Fri, 13 Aug 2004 09:37:03 +0000 Subject: [PATCH] Added WebGUI::HTTP::setNoHeader --- lib/WebGUI/Export.pm | 2 +- lib/WebGUI/HTTP.pm | 25 +++++++++++++++++++++++-- lib/WebGUI/Template.pm | 1 + 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/lib/WebGUI/Export.pm b/lib/WebGUI/Export.pm index 93c8afe7d..7e065294d 100644 --- a/lib/WebGUI/Export.pm +++ b/lib/WebGUI/Export.pm @@ -104,7 +104,7 @@ sub generate { # Disable printing of HTTP Header if requested. if($self->get('noHttpHeader')) { - $session{page}{noHttpHeader} = 1; + WebGUI::HTTP::setNoHeader(1); } # Set alternate Site URL diff --git a/lib/WebGUI/HTTP.pm b/lib/WebGUI/HTTP.pm index 2e5454b7d..4c55b983c 100644 --- a/lib/WebGUI/HTTP.pm +++ b/lib/WebGUI/HTTP.pm @@ -33,7 +33,8 @@ use WebGUI::HTTP; $header = WebGUI::HTTP::getHeader(); WebGUI::HTTP::setRedirect($url); WebGUI::HTTP::setCookie($name,$value); - + WebGUI::HTTP::setNoHeader($bool); + =head1 METHODS These subroutines are available from this package: @@ -51,7 +52,7 @@ Generates an HTTP header. =cut sub getHeader { - return undef if ($session{page}{noHttpHeader}); + return undef if ($session{http}{noHeader}); my $header; unless (exists $session{http}{location}) { unless ($session{http}{charset}) { @@ -195,6 +196,26 @@ sub setMimeType { $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; +} #------------------------------------------------------------------- diff --git a/lib/WebGUI/Template.pm b/lib/WebGUI/Template.pm index 2c50d31ee..804ffca27 100644 --- a/lib/WebGUI/Template.pm +++ b/lib/WebGUI/Template.pm @@ -234,6 +234,7 @@ sub process { unless (-f $file->getPath) { WebGUI::ErrorHandler::warn("Could not create file ".$file->getPath."\nTemplate file caching is disabled"); $params{scalarref} = \$template; + delete $params{filename}; } } return _execute(\%params,$vars);