vadvs (vadvs) wrote in changelog,
vadvs
vadvs
changelog

[bml] r131: Added header X-Accept-Encoding

Committer: vad
Added header X-Accept-Encoding
U   trunk/lib/Apache/BML.pm
Modified: trunk/lib/Apache/BML.pm
===================================================================
--- trunk/lib/Apache/BML.pm	2010-09-09 10:45:34 UTC (rev 130)
+++ trunk/lib/Apache/BML.pm	2010-10-05 09:19:59 UTC (rev 131)
@@ -404,11 +404,18 @@
         LJ::Request->header_out("ETag", $etag) if defined $etag;
 
         # gzip encoding
-        my $do_gzip = $env->{'DoGZIP'} && $Apache::BML::HAVE_ZLIB;
-        $do_gzip = 0 if $do_gzip && $content_type !~ m!^text/html!;
-        $do_gzip = 0 if $do_gzip && LJ::Request->header_in("Accept-Encoding") !~ /gzip/;
+        my $do_gzip = $env->{'DoGZIP'} && $Apache::BML::HAVE_ZLIB && $LJ::DO_GZIP;
         my $length = length($html);
-        $do_gzip = 0 if $length < 500;
+        if (LJ::Request->header_in("X-Accept-Encoding") =~ m/gzip/){
+            ## X-Accept-Encoding strictly demands gzip encoding
+            $do_gzip = 1 if $Apache::BML::HAVE_ZLIB; # do if we could
+        } else {
+            ## other weighing
+            $do_gzip = 0 if $do_gzip && $content_type !~ m!^text/html!;
+            $do_gzip = 0 if $do_gzip && LJ::Request->header_in("Accept-Encoding") !~ /gzip/;
+            $do_gzip = 0 if $length < 500;
+        }
+
         if ($do_gzip) {
             my $pre_len = $length;
             LJ::Request->notes("bytes_pregzip" => $pre_len);
@@ -2008,6 +2015,11 @@
     return "[ml_getter not defined]";
 }
 
+sub ml_multi {
+    my $codes = shift;
+    return LJ::Lang::get_text_multi(get_language(), undef, $codes);
+}
+
 sub eurl
 {
     my $a = $_[0];

Tags: bml, pm, vadvs
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments