nateps / connect-gzip Goto Github PK
View Code? Open in Web Editor NEWGzip middleware for node.js Connect and Express
Gzip middleware for node.js Connect and Express
Stumbled on this while looking into a reported issue with everyauth
.
The problem is that the session is not properly persisted just before the redirect. To reproduce:
name
, but they do not -- hence, the broken assertion in the gist.--Brian
I was running connect-gzip from a directory that has a space in one of its parent dirs, and that makes the exec commands fail.
The code should use an arguments array instead of a string for executing CLI tools like rm or gzip so that the arguments don't get processed by sh
.
Hello,
I'm getting some an error when I try to run a gulp script with gulp-connect and connect-gzip.
The problem is when I try to gzip an image file, the image is gziped and sent to the browser, but the server crashes.
This is my code:
const connect = require('gulp-connect'),
connectGzip = require('connect-gzip');
gulp.task('connect', function() {
connect.server({
root: 'public',
livereload: false,
port: 8080,
middleware: () => {
return [
connectGzip.gzip({ matchType: /text|javascript|json|image/ })
];
}
});
});
This is the error:
events.js:160
throw er; // Unhandled 'error' event
^
Error: write after end
at ServerResponse.write (_http_outgoing.js:443:15)
at Socket.<anonymous> (/Users/user/project/node_modules/connect-gzip/lib/gzip.js:93:15)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at Pipe.onread (net.js:551:20)
npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/Cellar/node/7.3.0/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v7.3.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `./node_modules/gulp/bin/gulp.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script './node_modules/gulp/bin/gulp.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the project package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ./node_modules/gulp/bin/gulp.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs project
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls project
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/user/project/npm-debug.log
Can anyone help me with this problem? It's a bug?
When quickly gzipping multiple files (multiple requests).
Probably related to this:
From that issue:
"Not a bug. In 0.8 you'd want to listen for the "close" event. See the "Changed / child_process" section at https://github.com/joyent/node/wiki/API-changes-between-v0.6-and-v0.8"
connect-gzip is not working with npm install in Node.0.4.12
It said "UNMET DEPENDENCY"
said it is not compatible with my version of node/npm but I'm using the Node.0.4.12 npm 1.0.93
I don't want to run this on Unstable Node 0.5 version. anyway I can make it run on 0.4.12?
The version in npm is 0.1.6, but it says 0.1.5 in package.json
here on github. Forgot to push?
In connect 2.3.7 the send
function was split into a separate module (senchalabs/connect@3ea7fa2), which breaks connect-gzip
. This is unfortunate because connect-gzip
specifies a very liberal version range in package.json
, so all fresh installs of connect-gzip
are broken right now.
My recommendation is to pin the connect
dependency at a specific version:
"dependencies": {
- "connect": ">=1 <2",
+ "connect": "=2.3.6",
"mime": ">=0.0.1"
},
... then release a new version of connect-gzip
asap.
Then later when we're ready to use the new connect API, we can pin it at whatever is the latest version at that point. It's a little more housekeeping, but much safer.
And yes, this just bit me upon upgrading a production server :/
Let it run for a while and you end up with tons of .gz files for every file that is being gzipped.
In lib/gzip.js, line 67,68
if ( code !== 200 || !~accept.indexOf('gzip') || !matchType.test(type) || encoding)
should perhaps have been
if ( code !== 200 || ~accept.indexOf('gzip') || !matchType.test(type) || encoding)
since !~accept.indexOf means found?
My config:
app.use(gzip.staticGzip(__dirname + '/static',{maxAge: 8640000000}));
When a directory instead of an actual file is requested (without trailing slash), the staticGzip provider exposes the internal path of this directory (e.g. /home/node/myfaultyproject/static/js) to the client via a 301 Response
connect.static doesn't do that... :-)
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.