cmy 02a04f55a0 2023-3-15 пре 2 година
..
example 02a04f55a0 2023-3-15 пре 2 година
node_modules 02a04f55a0 2023-3-15 пре 2 година
test 02a04f55a0 2023-3-15 пре 2 година
.travis.yml 02a04f55a0 2023-3-15 пре 2 година
LICENSE 02a04f55a0 2023-3-15 пре 2 година
index.js 02a04f55a0 2023-3-15 пре 2 година
package.json 02a04f55a0 2023-3-15 пре 2 година
readme.markdown 02a04f55a0 2023-3-15 пре 2 година

readme.markdown

oppressor

streaming http compression response negotiator

build status

example

You can use plain old streams:

var oppressor = require('oppressor');
var fs = require('fs');
var http = require('http');

var server = http.createServer(function (req, res) {
    fs.createReadStream(__dirname + '/data.txt')
        .pipe(oppressor(req))
        .pipe(res)
    ;
});
server.listen(8000);

or you can use fancy streaming static file server modules like filed that set handy things like etag, last-modified, and content-type headers for you:

(For now you'll need to use my fork until this pull request gets merged.)

var oppressor = require('oppressor');
var filed = require('filed');
var http = require('http');

var server = http.createServer(function (req, res) {
     filed(__dirname + '/data.txt')
        .pipe(oppressor(req))
        .pipe(res)
    ;
});
server.listen(8000);

methods

var oppressor = require('oppressor')

var stream = oppressor(req)

Return a duplex stream that will be compressed with gzip, deflate, or no compression depending on the accept-encoding headers sent.

oppressor will emulate calls to http.ServerResponse methods like writeHead() so that modules like filed that expect to be piped directly to the response object will work.

install

With npm do:

npm install oppressor

license

MIT