Skip to content

Commit

Permalink
Remove warning on being untested on node 8 and above
Browse files Browse the repository at this point in the history
  • Loading branch information
gustav-olsen-groupone committed Mar 4, 2019
1 parent 5a7f639 commit 55bceb8
Showing 1 changed file with 21 additions and 28 deletions.
49 changes: 21 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# WARNING

This module is currently not tested against node 8 or later. We have a couple of
known bugs and potential memory leaks when running on node versions 8 and newer.

# hijackresponse

[![npm version](https://badge.fury.io/js/hijackresponse.svg)](https://www.npmjs.com/package/hijackresponse)
Expand Down Expand Up @@ -41,32 +36,30 @@ $ npm install hijackresponse
## Usage

```js
var express = require('express');
var hijackResponse = require('hijackresponse');
var express = require("express");
var hijackResponse = require("hijackresponse");

var app = express();

app.use(function (req, res, next) {
hijackResponse(res, function (err, res) {
if (err) {
res.unhijack(); // Make the original res object work again
return next(err);
}

// Don't hijack HTML responses:
if (/^text\/html(?:;$)/.test(res.getHeader('Content-Type'))) {
return res.unhijack();
}

res.setHeader('X-Hijacked', 'yes!');
res.removeHeader('Content-Length');

res
.pipe(transformStream)
.pipe(res);
});
// next() must be called explicitly, even when hijacking the response:
next();
app.use(function(req, res, next) {
hijackResponse(res, function(err, res) {
if (err) {
res.unhijack(); // Make the original res object work again
return next(err);
}

// Don't hijack HTML responses:
if (/^text\/html(?:;$)/.test(res.getHeader("Content-Type"))) {
return res.unhijack();
}

res.setHeader("X-Hijacked", "yes!");
res.removeHeader("Content-Length");

res.pipe(transformStream).pipe(res);
});
// next() must be called explicitly, even when hijacking the response:
next();
});
```

Expand Down

0 comments on commit 55bceb8

Please sign in to comment.