From 70c6a9fdf3d422a4cd0fc80832a6ab699c99995c Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Thu, 21 May 2009 20:37:46 -0500 Subject: [PATCH] Bug 3239 - Content-Script-Type and Content-Style-Type This adds headers to define the default script and style languages. Please note that this output isn't 100% canonical from CGI yet, but that is due to a bug in CGI: http://bugs.koha.org/cgi-bin/bugzilla3/show_bug.cgi?id=3243 So either CGI will perfect it's output, or we can switch to using HTTP::Headers. The latter may be desirable anyway, since then we would not need a CGI $query argument at all. Signed-off-by: Galen Charlton --- C4/Output.pm | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/C4/Output.pm b/C4/Output.pm index f1cf80b064..6604ae07c0 100644 --- a/C4/Output.pm +++ b/C4/Output.pm @@ -373,37 +373,29 @@ sub output_with_http_headers($$$$;$) { my %content_type_map = ( 'html' => 'text/html', - 'js' => 'text/javascript', + 'js' => 'text/javascript', 'json' => 'application/json', - 'xml' => 'text/xml', + 'xml' => 'text/xml', # NOTE: not using application/atom+xml or application/rss+xml because of # Internet Explorer 6; see bug 2078. - 'rss' => 'text/xml', + 'rss' => 'text/xml', 'atom' => 'text/xml' ); die "Unknown content type '$content_type'" if ( !defined( $content_type_map{$content_type} ) ); - - if ($cookie) { - print $query->header( - -type => $content_type_map{$content_type}, - -status => $status, - -charset => 'UTF-8', - -cookie => $cookie, - -Pragma => 'no-cache', - -'Cache-Control' => 'no-cache', - ); - } else { - print $query->header( - -type => $content_type_map{$content_type}, - -status => $status, - -charset => 'UTF-8', - -Pragma => 'no-cache', - -'Cache-Control' => 'no-cache', - ); + my $options = { + type => $content_type_map{$content_type}, + status => $status, + charset => 'UTF-8', + Pragma => 'no-cache', + 'Cache-Control' => 'no-cache', + }; + $options->{cookie} = $cookie if $cookie; + if ($content_type eq 'html') { # guaranteed to be one of the content_type_map keys, else we'd have died + $options->{'Content-Style-Type' } = 'text/css'; + $options->{'Content-Script-Type'} = 'text/javascript'; } - - print $data; + print $query->header($options), $data; } sub output_html_with_http_headers ($$$) { -- 2.39.5