优化 response 拦截器,只在响应为200时生效。

pull/297/head
王良 8 months ago
parent 97de211cfb
commit 9ce2149810

@ -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 = ''

Loading…
Cancel
Save