You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dev-sidecar/packages/mitmproxy/test/lib/interceptor/impl/res/responseReplaceTest.js

32 lines
718 B

const responseReplace = require('../../../../../src/lib/interceptor/impl/res/responseReplace')
const headers = {}
const res = {
setHeader: (key, value) => {
headers[key] = value
}
}
const proxyRes = {
rawHeaders: [
'Content-Type', 'application/json; charset=utf-8',
'Content-Length', '2',
'ETag', 'W/"2"',
'Date', 'Thu, 01 Jan 1970 00:00:00 GMT',
'Connection', 'keep-alive'
]
}
const newHeaders = {
'Content-Type': 'application/json; charset=utf-8',
'Content-Length': '3',
xxx: 1,
Date: '[remove]',
yyy: '[remove]'
}
const result = responseReplace.replaceResponseHeaders(newHeaders, res, proxyRes)
console.log(proxyRes.rawHeaders)
console.log(headers)
console.log(result)