[Koha-patches] [PATCH] Bug 3239 - Content-Script-Type and Content-Style-Type

Joe Atzberger joe.atzberger at liblime.com
Fri May 22 03:37:46 CEST 2009


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.
---
 C4/Output.pm |   38 +++++++++++++++-----------------------
 1 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/C4/Output.pm b/C4/Output.pm
index f1cf80b..6604ae0 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 ($$$) {
-- 
1.5.6.5



More information about the Koha-patches mailing list