New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-http-proxy-json

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-http-proxy-json - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

16

index.js

@@ -10,6 +10,16 @@ 'use strict';

* @param res {Response} The http response
* @param contentEncoding {String} The http header content-encoding: gzip/deflate
* @param proxyRes {proxyRes|String} String: The http header content-encoding: gzip/deflate
* @param callback {Function} Custom modified logic
*/
module.exports = function modifyResponse(res, contentEncoding, callback) {
module.exports = function modifyResponse(res, proxyRes, callback) {
let contentEncoding = proxyRes;
if (proxyRes && proxyRes.headers) {
contentEncoding = proxyRes.headers['content-encoding'];
// Delete the content-length if it exists. Otherwise, an exception will occur
// @see: https://github.com/langjt/node-http-proxy-json/issues/10
if ('content-length' in proxyRes.headers) {
delete proxyRes.headers['content-length'];
}
}
let unzip, zip;

@@ -33,3 +43,3 @@ // Now only deal with the gzip/deflate/undefined content-encoding.

if (unzip) {
unzip.on('error', function(e) {
unzip.on('error', function (e) {
console.log('Unzip error: ', e);

@@ -36,0 +46,0 @@ _end.call(res);

2

package.json
{
"name": "node-http-proxy-json",
"version": "0.1.4",
"version": "0.1.5",
"description": "for node-http-proxy transform the response json from the proxied server.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -33,3 +33,3 @@ # node-http-proxy-json [![Build Status](https://travis-ci.org/langjt/node-http-proxy-json.svg?branch=master)](https://travis-ci.org/langjt/node-http-proxy-json)

proxy.on('proxyRes', function (proxyRes, req, res) {
modifyResponse(res, proxyRes.headers['content-encoding'], function (body) {
modifyResponse(res, proxyRes, function (body) {
if (body) {

@@ -92,3 +92,3 @@ // modify some information

proxy.on('proxyRes', function (proxyRes, req, res) {
modifyResponse(res, proxyRes.headers['content-encoding'], function (body) {
modifyResponse(res, proxyRes, function (body) {
if (body) {

@@ -150,3 +150,3 @@ // modify some information

proxy.on('proxyRes', function (proxyRes, req, res) {
modifyResponse(res, proxyRes.headers['content-encoding'], function (body) {
modifyResponse(res, proxyRes, function (body) {
if (body) {

@@ -153,0 +153,0 @@ // modify some information

@@ -71,3 +71,3 @@ 'use strict';

proxy.on('proxyRes', (proxyRes, req, res) => {
modifyResponse(res, proxyRes.headers['content-encoding'], body => {
modifyResponse(res, proxyRes, body => {
if (body) {

@@ -109,3 +109,3 @@ // modify some information

proxy.on('proxyRes', (proxyRes, req, res) => {
modifyResponse(res, proxyRes.headers['content-encoding'], body => {
modifyResponse(res, proxyRes, body => {
if (body) {

@@ -112,0 +112,0 @@ // modify some information

@@ -72,3 +72,3 @@ 'use strict';

proxy.on('proxyRes', (proxyRes, req, res) => {
modifyResponse(res, proxyRes.headers['content-encoding'], body => {
modifyResponse(res, proxyRes, body => {
if (body) {

@@ -111,3 +111,3 @@ // modify some information

proxy.on('proxyRes', (proxyRes, req, res) => {
modifyResponse(res, proxyRes.headers['content-encoding'], body => {
modifyResponse(res, proxyRes, body => {
if (body) {

@@ -114,0 +114,0 @@ // modify some information

@@ -55,3 +55,3 @@ 'use strict';

proxy.on('proxyRes', function(proxyRes, req, res) {
modifyResponse(res, proxyRes.headers['content-encoding'], body => {
modifyResponse(res, proxyRes, body => {
if (body) {

@@ -86,3 +86,3 @@ // modify some information

proxy.on('proxyRes', (proxyRes, req, res) => {
modifyResponse(res, proxyRes.headers['content-encoding'], body => {
modifyResponse(res, proxyRes, body => {
if (body) {

@@ -89,0 +89,0 @@ // modify some information

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