Browse Source

小调整

pull/303/head
王良 7 months ago
parent
commit
0b03e5f975
  1. 2
      packages/gui/extra/scripts/tampermonkey.script
  2. 8
      packages/mitmproxy/src/lib/interceptor/impl/res/AfterOPTIONSHeaders.js
  3. 5
      packages/mitmproxy/src/lib/interceptor/impl/res/responseReplace.js

2
packages/gui/extra/scripts/tampermonkey.script

@ -35,7 +35,7 @@
.____ds-icon____{
position: fixed;
right: 5px;
top: 35%;
top: 30%;
z-index: 9999;
width: 36px;
height: 36px;

8
packages/mitmproxy/src/lib/interceptor/impl/res/AfterOPTIONSHeaders.js

@ -16,10 +16,10 @@ module.exports = {
}
// 替换响应头
responseReplaceApi.replaceResponseHeaders(headers, res, proxyRes)
res.setHeader('DS-AfterOPTIONSHeaders-Interceptor', true)
log.info('AfterOPTIONSHeaders intercept:', JSON.stringify(headers))
if (responseReplaceApi.replaceResponseHeaders(headers, res, proxyRes)) {
res.setHeader('DS-AfterOPTIONSHeaders-Interceptor', true)
log.info('AfterOPTIONSHeaders intercept:', JSON.stringify(headers))
}
},
is (interceptOpt) {
return !!interceptOpt.options

5
packages/mitmproxy/src/lib/interceptor/impl/res/responseReplace.js

@ -38,7 +38,7 @@ function replaceResponseHeaders (newHeaders, res, proxyRes) {
// 新增响应头
for (const headerKey in newHeaders) {
const headerValue = newHeaders[headerKey]
if (!headerValue || headerValue === REMOVE) {
if (headerValue == null || headerValue === REMOVE) {
continue
}
@ -46,6 +46,9 @@ function replaceResponseHeaders (newHeaders, res, proxyRes) {
preHeaders[headerKey] = null // 标记原先响应头为null
}
if (lodash.isEmpty(preHeaders)) {
return null
}
// 返回原先响应头
return preHeaders
}

Loading…
Cancel
Save