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

rocky

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rocky - npm Package Compare versions

Comparing version 0.3.4 to 0.3.5

34

lib/middleware/response-body.js

@@ -17,2 +17,3 @@ const common = require('./common')

var length = 0
var closed = false
var headArgs = null

@@ -30,2 +31,5 @@

res.write = function (data) {
var cb = getCallback(arguments)
if (closed) return cb && cb()
if (data) {

@@ -36,3 +40,2 @@ length += +data.length || 0

var cb = getCallback(arguments)
if (cb) cb()

@@ -42,2 +45,5 @@ }

res.end = function (data) {
var cb = getCallback(arguments)
if (closed) return cb && cb()
if (data && typeof data !== 'function') {

@@ -49,2 +55,19 @@ buf.push(data)

// Expose the body
res.body = res._originalBody = body
// Restore and clean references
cleanupAndRestore()
middleware(req, res, finisher(cb))
}
req.on('close', onClose)
function onClose() {
closed = true
cleanupAndRestore()
}
function cleanupAndRestore() {
// Restore methods

@@ -55,10 +78,5 @@ res.writeHead = _writeHead

// Expose the body
res.body = res._originalBody = body
// Clean references to prevent leaks
buf = body = _end = _write = headArgs = null
var cb = getCallback(arguments)
middleware(req, res, finisher(cb))
req.removeListener('close', onClose)
}

@@ -68,2 +86,4 @@

return function (err, body, encoding) {
if (closed) return cb && cb()
if (err) {

@@ -70,0 +90,0 @@ res.statusCode = +err.status || 500

{
"name": "rocky",
"version": "0.3.4",
"version": "0.3.5",
"description": "Full-featured, middleware-oriented HTTP proxy with traffic replay and intercept",

@@ -5,0 +5,0 @@ "repository": "h2non/rocky",

const expect = require('chai').expect
const Emitter = require('events').EventEmitter
const middleware = require('../../lib/middleware')

@@ -16,2 +17,6 @@ const noop = function () {}

beforeEach(function () {
req = new Emitter
})
function middlewareFn(req, res, next) {

@@ -37,3 +42,3 @@ var body = res.body.toString()

(middlewareFn)
(null, res, noop)
(req, res, noop)

@@ -55,3 +60,3 @@ writeData()

(middlewareFn, filter)
(null, res, noop)
(req, res, noop)

@@ -58,0 +63,0 @@ writeData()

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