Socket
Socket
Sign inDemoInstall

http-proxy

Package Overview
Dependencies
2
Maintainers
4
Versions
85
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.16.1 to 1.16.2

1

lib/http-proxy.js

@@ -38,2 +38,3 @@ // Use explicit /index.js to help browserify negociation in require '/lib/http-proxy' (!)

* changeOrigin: <true/false, Default: false - changes the origin of the host header to the target URL>
* preserveHeaderKeyCase: <true/false, Default: false - specify whether you want to keep letter case of response header key >
* auth : Basic authentication i.e. 'user:password' to compute an Authorization header.

@@ -40,0 +41,0 @@ * hostRewrite: rewrites the location hostname on (301/302/307/308) redirects, Default: null.

34

lib/http-proxy/passes/web-outgoing.js

@@ -87,14 +87,10 @@ var url = require('url'),

var rewriteCookieDomainConfig = options.cookieDomainRewrite,
// In proxyRes.rawHeaders Set-Cookie headers are sparse.
// so, we'll collect Set-Cookie headers, and set them in the response as an array.
setCookies = [],
preserveHeaderKeyCase = options.preserveHeaderKeyCase,
rawHeaderKeyMap,
setHeader = function(key, header) {
if (header == undefined) return;
if (key.toLowerCase() !== 'set-cookie') {
return res.setHeader(String(key).trim(), header);
}
if (rewriteCookieDomainConfig) {
if (rewriteCookieDomainConfig && key.toLowerCase() === 'set-cookie') {
header = common.rewriteCookieDomain(header, rewriteCookieDomainConfig);
}
setCookies.push(header); // defer to the end when we have all of them
res.setHeader(String(key).trim(), header);
};

@@ -108,17 +104,17 @@

// https://nodejs.org/api/http.html#http_message_rawheaders
if (proxyRes.rawHeaders != undefined) {
if (preserveHeaderKeyCase && proxyRes.rawHeaders != undefined) {
rawHeaderKeyMap = {};
for (var i = 0; i < proxyRes.rawHeaders.length; i += 2) {
var key = proxyRes.rawHeaders[i];
var header = proxyRes.rawHeaders[i + 1];
setHeader(key, header);
rawHeaderKeyMap[key.toLowerCase()] = key;
}
} else {
Object.keys(proxyRes.headers).forEach(function(key) {
var header = proxyRes.headers[key];
setHeader(key, header);
});
}
if (setCookies.length) {
res.setHeader('Set-Cookie', setCookies.length === 1 ? setCookies[0] : setCookies);
}
Object.keys(proxyRes.headers).forEach(function(key) {
var header = proxyRes.headers[key];
if (preserveHeaderKeyCase && rawHeaderKeyMap) {
key = rawHeaderKeyMap[key] || key;
}
setHeader(key, header);
});
},

@@ -125,0 +121,0 @@

{
"name": "http-proxy",
"version": "1.16.1",
"version": "1.16.2",
"repository": {

@@ -5,0 +5,0 @@ "type": "git",

@@ -336,2 +336,3 @@ <p align="center">

* **changeOrigin**: true/false, Default: false - changes the origin of the host header to the target URL
* **preserveHeaderKeyCase**: true/false, Default: false - specify whether you want to keep letter case of response header key
* **auth**: Basic authentication i.e. 'user:password' to compute an Authorization header.

@@ -338,0 +339,0 @@ * **hostRewrite**: rewrites the location hostname on (201/301/302/307/308) redirects.

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc