plack / plack-middleware-deflater Goto Github PK
View Code? Open in Web Editor NEWgzip/deflate content encoding middleware for Plack
Home Page: http://search.cpan.org/dist/Plack-Middleware-Deflater
License: Other
gzip/deflate content encoding middleware for Plack
Home Page: http://search.cpan.org/dist/Plack-Middleware-Deflater
License: Other
Test of Furl's t/100_low/13_deflate.t
is passed with Plack::Middleware::[email protected]
, but it is failed with Plack::Middleware::[email protected]
.
% cpanm -q Plack::Middleware::[email protected]
Successfully installed Plack-Middleware-Deflater-0.09 (downgraded from 0.10)
1 distribution installed
% prove -b t/100_low/13_deflate.t
t/100_low/13_deflate.t .. ok
All tests successful.
Files=1, Tests=240, 1 wallclock secs ( 0.05 usr 0.00 sys + 0.97 cusr 0.09 csys = 1.11 CPU)
Result: PASS
% cpanm -q Plack::Middleware::[email protected]
Successfully installed Plack-Middleware-Deflater-0.10 (upgraded from 0.09)
1 distribution installed
% prove -b t/100_low/13_deflate.t
t/100_low/13_deflate.t .. 1/? Uncompress error: data error at /home/syohei/.cpanm/work/1375777569.30022/Furl-2.17/blib/lib/Furl/HTTP.pm line 760.
# Tests were run but no plan was declared and done_testing() was not seen.
t/100_low/13_deflate.t .. Dubious, test returned 255 (wstat 65280, 0xff00)
All 1 subtests passed
Test Summary Report
-------------------
t/100_low/13_deflate.t (Wstat: 65280 Tests: 1 Failed: 0)
Non-zero exit status: 255
Parse errors: No plan found in TAP output
Files=1, Tests=1, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.10 cusr 0.01 csys
= 0.13 CPU)
Result: FAIL
Another example.
# app.psgi
use strict;
use warnings;
use Plack::Builder;
my $app = sub {
return [200, [], ["Hello World"]];
};
builder {
enable "Deflater";
$app;
};
% curl --compressed http://localhost:5000 # plackup app.psgi with Version 0.09
Hello World
% curl --compressed http://localhost:5000 # plackup app.psgi with Version 0.10
curl: (61) Error while processing content unencoding: invalid block type
Your missing a new line before
=HEAD1 DESCRIPTION
See http://search.cpan.org/~kazeburo/Plack-Middleware-Deflater-0.04/lib/Plack/Middleware/Deflater.pm
Thanks for this module.
because we have to wait for the underlying response to determine content_type.
right now you have to do:
enable 'Deflater';
enable sub { my $app = shift;
sub { my $env = shift;
my $res = $app->($env);
# skip streamy response
return $res unless ref($res) eq 'ARRAY' && $res->[2];
my $h = Plack::Util::headers($res->[1]);
my $type = $h->get('Content-Type')
or return $res;
delete $env->{HTTP_ACCEPT_ENCODING}
unless $type =~ m|application/x-javascript| || $type =~ m|^text/|;
$res }
};
but this doesn't disable the middleware completely, the side-effect is that deflater still removes the content-length header and adds vary header for your image/png responses, which is probably not cache-friendly
deflate response doesn't get decoded properly by LWP clients and Firefox.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.