Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hijackresponse

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hijackresponse - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

4

lib/hijackResponse.js

@@ -54,5 +54,5 @@ var Readable = require('stream').Readable

hijackedResponse.emit('close')
} else {
return resEmit.apply(this, arguments)
}
return resEmit.apply(this, arguments)
}

@@ -59,0 +59,0 @@

{
"name": "hijackresponse",
"version": "2.0.0",
"version": "2.0.1",
"description": "Hijack HttpResponses",

@@ -5,0 +5,0 @@ "main": "lib/hijackResponse.js",

@@ -1,5 +0,7 @@

/* global describe, it */
/* global describe, it, before, after */
var http = require('http')
var expect = require('unexpected')
.clone()
.use(require('unexpected-express'))
.use(require('unexpected-sinon'))
.addAssertion('to yield response', function (expect, subject, value) {

@@ -11,2 +13,3 @@ return expect(subject, 'to yield exchange', {

})
var sinon = require('sinon')
var express = require('express')

@@ -167,2 +170,63 @@ var passError = require('passerror')

})
describe('against a real server', function () {
before(function () {
var self = this
var spy = sinon.spy()
this.spy = spy
return new Promise(function (resolve) {
var app = express()
.use(function (req, res, next) {
res.on('close', function () {
spy()
self.resolve()
})
next()
})
.use(function (req, res, next) {
hijackResponse(res, passError(next, function (res) {
res.pipe(res)
}))
next()
})
.use(function (req, res) {
res.write('foo')
})
var server = http.Server(app)
server.listen(0, function () {
resolve(server)
})
}).then(function (server) {
self.server = server
})
})
it('should not prevent "close" events registered on res from firing when hijacking', function () {
var self = this
var port = this.server.address().port
var spy = this.spy
return new Promise(function (resolve) {
self.resolve = resolve
var options = {
port: port
}
var request = http.request(options, function (res) {
request.abort()
})
request.end()
}).then(function () {
expect(spy, 'was called')
})
})
after(function () {
this.server.close()
})
})
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc