node-http-proxy-json
Advanced tools
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); |
{ | ||
"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 |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
20508
460
6