Skip to content

Instantly share code, notes, and snippets.

@ipiyer
Created December 29, 2015 23:56
Show Gist options
  • Save ipiyer/526f16bf03f1b6763550 to your computer and use it in GitHub Desktop.
Save ipiyer/526f16bf03f1b6763550 to your computer and use it in GitHub Desktop.
terminate http stream
var request = require("request");
exports.foo = function(req, res) {
request.get("foo.com")
.on('response', function(){
if (response.statusCode === 404) {
// terminate and return {"error": "not found"}
// How do i do this?
}
})
.pipe(res);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment