Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 70 lines (50 sloc) 1.545 kb
5dff71c @substack headers successfully pass through from filed through to the response
authored
1 # oppressor
2
fad5729 @substack package.json etc
authored
3 streaming http compression response negotiator
5dff71c @substack headers successfully pass through from filed through to the response
authored
4
859064a @substack using travis
authored
5 [![build status](https://secure.travis-ci.org/substack/oppressor.png)](http://travis-ci.org/substack/oppressor)
6
5dff71c @substack headers successfully pass through from filed through to the response
authored
7 # example
8
b0392de @substack docs
authored
9 You can use plain old streams:
10
11 ``` js
12 var oppressor = require('oppressor');
13 var fs = require('fs');
14 var http = require('http');
15
16 var server = http.createServer(function (req, res) {
17 fs.createReadStream(__dirname + '/data.txt')
18 .pipe(oppressor(req))
19 .pipe(res)
20 ;
21 });
22 server.listen(8000);
23 ```
24
25 or you can use fancy streaming static file server modules like
26 [filed](http://github.com/mikeal/filed) that set handy things like etag,
27 last-modified, and content-type headers for you:
28
29 ``` js
30 var oppressor = require('oppressor');
31 var filed = require('filed');
32 var http = require('http');
33
34 var server = http.createServer(function (req, res) {
35 filed(__dirname + '/data.txt')
36 .pipe(oppressor(req))
37 .pipe(res)
38 ;
39 });
40 server.listen(8000);
41 ```
42
43 # methods
44
5dff71c @substack headers successfully pass through from filed through to the response
authored
45 ``` js
b0392de @substack docs
authored
46 var oppressor = require('oppressor')
5dff71c @substack headers successfully pass through from filed through to the response
authored
47 ```
b0392de @substack docs
authored
48
49 ## var stream = oppressor(req)
50
51 Return a [duplex stream](https://github.com/substack/stream-handbook#duplex)
52 that will be compressed with gzip, deflate, or no compression depending on the
53 accept-encoding headers sent.
54
55 oppressor will emulate calls to http.ServerResponse methods like `writeHead()`
56 so that modules like [filed](http://github.com/mikeal/filed) that expect to be
57 piped directly to the response object will work.
58
59 # install
60
61 With [npm](https://npmjs.org) do:
62
63 ```
64 npm install oppressor
65 ```
66
67 # license
68
69 MIT
Something went wrong with that request. Please try again.