Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added proxy over deprecated responseHeaders to make object case-insensitive #1022

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions lib/sandbox/postman-legacy-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,19 @@ const _ = require('lodash'),
URLENCODED: 'urlencoded',
FORMDATA: 'formdata',
FILE: 'file'
},

/**
* Proxy handler for response headers to make them case-insensitive.
*/
responseHeadersProxyHandler = {
get: (target, key) => {
if (key === 'hasOwnProperty') {
return (prop) => { return Reflect.has(target, prop.toLowerCase()); };
}

return target[key.toLowerCase()];
}
};

function getRequestBody (request) {
Expand Down Expand Up @@ -386,15 +399,18 @@ module.exports = {
globalvars.responseCookies = execution.cookies || [];

/**
* Stores the response headers with the keys being case sensitive
* Stores the response headers with case insensitive keys
*
* @memberOf SandboxGlobals
* @type {Array.<Object>}
*/
globalvars.responseHeaders = {};

const responseHeaders = {};

execution.response && execution.response.headers.each(function (header) {
header && !header.disabled && (globalvars.responseHeaders[header.key] = header.value);
header && !header.disabled && (responseHeaders[header.key.toLowerCase()] = header.value);
});
globalvars.responseHeaders = new Proxy(responseHeaders, responseHeadersProxyHandler);

/**
* @memberOf SandboxGlobals
Expand Down
Loading