Skip Menu |

This queue is for tickets about the MasonX-Plugin-Compress CPAN distribution.

Report information
The Basics
Id: 18424
Status: new
Priority: 0/
Queue: MasonX-Plugin-Compress

People
Owner: Nobody in particular
Requestors: shane [...] aptest.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.1
Fixed in: (no value)



Subject: Bugs prevent working with CGI and apache 2 / mod_perl 2
The original module tried to detect whether it was running under cgi, but in a way that didn't quite work. I attach patches that resolve that, and also that make it work under mod_perl 1 or mod_perl 2 apache.
Subject: cdiffs.txt
*** Compress.pm.orig Tue Mar 28 21:21:47 2006 --- Compress.pm Tue Mar 28 21:44:13 2006 *************** *** 56,62 **** my $o = $context->output; my $m = $context->request; ! my $r = $m->apache_req || $m->cgi_request; return unless length $$o; --- 56,67 ---- my $o = $context->output; my $m = $context->request; ! my $r ; ! if ($m->can("apache_req")) { ! $r = $m->apache_req ; ! } elsif ($m->can("cgi_request")) { ! $r = $m->cgi_request; ! } return unless length $$o; *************** *** 67,78 **** # not sure from the docs if results->[0] contains the request return code, but # it seems to - does this break CGI? Anyway, seems to be undef. #return unless $context->result->[0] == Apache::Constants::OK(); ! # maybe worth accepting a few others, see e.g. http://www.pipeboost.com/contenttypes.asp ! return unless $r->content_type =~ /^text/; # FireFox gives gzip, deflate ! return unless my @accept = split /[\s,]/, $r->header_in( 'Accept-Encoding' ); return unless my $encoding = List::Util::first { $AcceptMap{ $_ } } @accept; --- 72,91 ---- # not sure from the docs if results->[0] contains the request return code, but # it seems to - does this break CGI? Anyway, seems to be undef. #return unless $context->result->[0] == Apache::Constants::OK(); ! # maybe worth accepting a few others, see e.g. http://www.pipeboost.com/contenttypes.asp ! my $type = $r->content_type || "text/html" ; ! return unless $type =~ /^text/; # FireFox gives gzip, deflate ! my $hdr; ! if ($r->can("headers_in") ) { ! $hdr = $r->headers_in()->{'Accept-Encoding'}; ! } elsif ($r->can("header_in")) { ! $hdr = $r->header_in( 'Accept-Encoding' ) ; ! } ! ! return unless my @accept = split /[\s,]/, $hdr; return unless my $encoding = List::Util::first { $AcceptMap{ $_ } } @accept; *************** *** 88,98 **** my ( $class, $context, $enc ) = @_; my $m = $context->request; ! my $r = $m->apache_req || $m->cgi_request; $r->content_encoding( $enc ); ! $r->header_out( Vary => 'Accept-Encoding' ); # I guess Mason sets this #$r->content_length( length ${ $context->output } ); --- 101,120 ---- my ( $class, $context, $enc ) = @_; my $m = $context->request; ! my $r ; ! if ($m->can("apache_req")) { ! $r = $m->apache_req ; ! } elsif ($m->can("cgi_request")) { ! $r = $m->cgi_request; ! } $r->content_encoding( $enc ); ! if ($r->can("headers_out") ) { ! $r->headers_out()->add('Vary' => 'Accept-Encoding' ); ! } elsif ($r->can("header_out")) { ! $r->header_out( Vary => 'Accept-Encoding' ) ; ! } # I guess Mason sets this #$r->content_length( length ${ $context->output } );