diff --git a/packages/mitmproxy/src/lib/interceptor/impl/res/response.js b/packages/mitmproxy/src/lib/interceptor/impl/res/response.js index c924a409..fc0ce27b 100644 --- a/packages/mitmproxy/src/lib/interceptor/impl/res/response.js +++ b/packages/mitmproxy/src/lib/interceptor/impl/res/response.js @@ -22,9 +22,8 @@ function replaceHeaders (newHeaders, res, proxyRes) { const headerKeyLower = headerKey.toLowerCase() const newHeaderValue = newHeaders[headerKeyLower] - if (newHeaderValue) { + if (newHeaderValue && newHeaderValue !== proxyRes.rawHeaders[i + 1]) { preHeaders[headerKeyLower] = proxyRes.rawHeaders[i + 1] // 先保存原先响应头 - proxyRes.rawHeaders[i + 1] = newHeaderValue delete newHeaders[headerKeyLower] } @@ -49,6 +48,10 @@ module.exports = { responseIntercept (context, interceptOpt, req, res, proxyReq, proxyRes, ssl, next) { const { log } = context + if (proxyRes.statusCode !== 200) { + return + } + const responseConfig = interceptOpt.response let actions = ''