【问题标题】:How do I get browsermob-proxy to record ALL response bodies如何让 browsermob-proxy 记录所有响应主体
【发布时间】:2018-07-26 11:06:10
【问题描述】:

我在使用 browsermob-proxy 及其 har 导出功能时遇到问题。一些响应正文未记录(缺少整个“文本”字段)

我的设置(使用 browsermob-proxy 2.1.4)

curl -X POST http://localhost:8080/proxy?port=9091

curl -X PUT "http://localhost:8080/proxy/9091/har?captureHeaders=true&captureCookies=true&captureContent=true"

有些反应很好:

"response": { "status": 201, "statusText": "Created", "httpVersion": "HTTP/1.1", "cookies": [], "headers": [{ "name": "Cache-Control", "value": "max-age=0, no-cache, no-store" }, { "name": "Content-Type", "value": "application/json" }, { "name": "Date", "value": "Thu, 15 Feb 2018 13:07:39 GMT" }, { "name": "Location", "value": ... }, { "name": "Pragma", "value": "no-cache" }, { "name": "Render-Time", "value": "8" }, { "name": "Server", "value": "openresty" }, { "name": "Strict-Transport-Security", "value": "max-age=31536000; includeSubDomains" }, { "name": "transfer-encoding", "value": "chunked" }, { "name": "Connection", "value": "keep-alive" }], "content": { "size": 8607, "mimeType": "application/json", "text": "{ <actual json body> }", "comment": "" }, ...

但有些不是(可能是特殊的内容/mime 类型?或者可能是 gzip 内容编码?)

"response": { "status": 200, "statusText": "OK", "httpVersion": "HTTP/1.1", "cookies": [], "headers": [{ "name": "Cache-Control", "value": "max-age=0, no-cache, no-store" }, { "name": "Content-Encoding", "value": "gzip" }, { "name": "Content-Type", "value": "application/some.custom.type-v1+json" }, { "name": "Date", "value": "Thu, 15 Feb 2018 13:07:39 GMT" }, { "name": "Pragma", "value": "no-cache" }, { "name": "Render-Time", "value": "92" }, { "name": "Server", "value": "openresty" }, { "name": "Strict-Transport-Security", "value": "max-age=31536000; includeSubDomains" }, { "name": "Vary", "value": "Accept-Encoding" }, { "name": "Content-Length", "value": "1978" }, { "name": "Connection", "value": "keep-alive" }], "content": { "size": 7429, "mimeType": "application/some.custom.type-v1+json", "comment": "" < there's nothing else here!! > }, "redirectURL": "", "headersSize": 444, "bodySize": 1978, "comment": "" }, ...

哦,是的,两个请求都通过 https,使用 MITM。

【问题讨论】:

    标签: browsermob-proxy har little-proxy


    【解决方案1】:

    我想我找到了自己问题的答案

    在 BrowserMobHttpClient.java 中我发现了以下内容:

    private boolean hasTextualContent(String contentType) {
        return contentType != null && contentType.startsWith("text/") ||
                contentType.startsWith("application/x-javascript") ||
                contentType.startsWith("application/javascript")  ||
                contentType.startsWith("application/json")  ||
                contentType.startsWith("application/xml")  ||
                contentType.startsWith("application/xhtml+xml");
    }
    

    看来我得制作一个自定义的 browsermob-proxy 版本才能让它工作。

    【讨论】:

    • Cyber​​Wiz,你改变了什么?我还面临它不记录 Content-Encoding 标头的问题。请让我知道 BrowserMobHttpClient.java 中的变化。提前致谢
    • 我刚刚为我的特定内容类型添加了一行,例如 || contentType.startsWith("application/some.custom.type-v1+json")
    猜你喜欢
    • 2018-10-22
    • 2023-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-01
    • 2017-12-27
    • 2017-02-13
    相关资源
    最近更新 更多