Skip to content

Adding callback to res.write and res.end for streaming support #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 20 commits into from
Closed
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,15 @@ function compression (options) {
var _on = res.on
var _write = res.write

var flushCB = function flushCB () {
stream.flush()
}

// flush
res.flush = function flush () {
if (stream) {
stream.flush()
// call write and pass flushCB to force synchronous behavior
stream.write('', flushCB)
}
}

Expand Down