diff --git a/packages/mitmproxy/src/json.js b/packages/mitmproxy/src/json.js index bfb82adefe..3094a5bcb3 100644 --- a/packages/mitmproxy/src/json.js +++ b/packages/mitmproxy/src/json.js @@ -15,10 +15,14 @@ module.exports = { // 仅用于记录日志时使用 stringify2 (obj) { try { - return JSON5.stringify(obj) + return JSON.stringify(obj) } catch (e) { - log.debug('转换为JSON字符串失败, error:', e, ', obj:', obj) - return obj + try { + return JSON5.stringify(obj) + } catch (e2) { + log.debug('转换为JSON字符串失败, error:', e, ', obj:', obj) + return obj + } } } } diff --git a/packages/mitmproxy/src/lib/proxy/mitmproxy/createRequestHandler.js b/packages/mitmproxy/src/lib/proxy/mitmproxy/createRequestHandler.js index 094cb836d5..ec3727fa02 100644 --- a/packages/mitmproxy/src/lib/proxy/mitmproxy/createRequestHandler.js +++ b/packages/mitmproxy/src/lib/proxy/mitmproxy/createRequestHandler.js @@ -106,7 +106,7 @@ module.exports = function createRequestHandler (createIntercepts, middlewares, e function onFree () { url = `${rOptions.method} ➜ ${rOptions.protocol}//${rOptions.hostname}:${rOptions.port}${rOptions.path}` const start = new Date() - log.info('发起代理请求:', url, (rOptions.servername ? ', sni: ' + rOptions.servername : ''), ', headers:', rOptions.headers) + log.info('发起代理请求:', url, (rOptions.servername ? ', sni: ' + rOptions.servername : ''), ', headers:', jsonApi.stringify2(rOptions.headers)) const isDnsIntercept = {} if (dnsConfig && dnsConfig.providers) {