browsermob-proxy
browsermob-proxy copied to clipboard
All browsermob-proxy-intercepted requests have empty content (body), but the request's body is not actually empty, why is this happening?
I am using browser mob 2.1.5 with Selenium in Java and trying to capture the body of requests in FireFox on a remote Selenium Server. The requests are sent to an HTTPS webpage.
I initiate a request filter in my code and try to capture the content (body) of the requests, but they all appear empty and I do not understand why? When the compiler reaches the contents variable I get a nullPointException, because it = null. This happens also for all responses. Am I missing some code or configuration?
For comparison, however, I manage to intercept the HttpRequest request and the HttpMessageInfo messageInfo. I am using BrowserMobProxy and BrowserMobProxyServer and NOT the legacy!!!
-
I tried to install the browsermob certificate in the FireFox browser in trusted authorities section.
-
I also set the following (nevertheless, the result is the same with and without the below-set capabilities):
// SSL related opts.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); opts.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true); opts.addArguments("--ignore-certificate-errors");
and this is what I am trying to do within the test before I execute an action in the UI:
String expectedContents = "subFolder2";
RequestFilter filter = new RequestFilter() {
@Override
public HttpResponse filterRequest(HttpRequest request, HttpMessageContents contents,
HttpMessageInfo messageInfo) {
if (request.getMethod().toString().equals("POST")) {
if (contents.getTextContents().contains(expectedContents)) {
contents.setTextContents("{\"newFilePath\":\"/subFolder2/FileWithChangedName\"}");
}
}
// in the request filter, you can return an HttpResponse object to "short-circuit" the request
return null;
}
};
proxy.addRequestFilter(filter);
userUiPage.moveActionButtonInMoveWindowClick();
I expect to capture at least one post request with the following payload / body (of type JSON) so that I can change it:
{"newFilePath":"/subFolder2/TestFile"}
i've faced a similar problem, and by debuging cause i found the target website uses Brotli compress algorithm, but browsermob-proxy only supports GZip decompression and other 'encoding-content' type content will be automaticlly decompressd as base64 binary data, therefore the content text is either empty or unusable
i've faced a similar problem, and by debuging cause i found the target website uses Brotli compress algorithm, but browsermob-proxy only supports GZip decompression and other 'encoding-content' type content will be automaticlly decompressd as base64 binary data, therefore the content text is either empty or unusable
how to solve this problem? I'm facing this promble too, and its Response headers has one field that is “content-encoding: br”。So Dose it use Brotli compress algorithm?
i've faced a similar problem, and by debuging cause i found the target website uses Brotli compress algorithm, but browsermob-proxy only supports GZip decompression and other 'encoding-content' type content will be automaticlly decompressd as base64 binary data, therefore the content text is either empty or unusable
how to solve this problem? I'm facing this promble too, and its Response headers has one field that is “content-encoding: br”。So Dose it use Brotli compress algorithm?
I have also encountered this problem. Can I seek help or how can I change the response to remove the br?
i've faced a similar problem, and by debuging cause i found the target website uses Brotli compress algorithm, but browsermob-proxy only supports GZip decompression and other 'encoding-content' type content will be automaticlly decompressd as base64 binary data, therefore the content text is either empty or unusable
how to solve this problem? I'm facing this promble too, and its Response headers has one field that is “content-encoding: br”。So Dose it use Brotli compress algorithm?
I have also encountered this problem. Can I seek help or how can I change the response to remove the br?
Yes, 'Br' stands for Brotli compress algorithm. If I remember it correctly there isn't an ideal workaround for this problem, the only thing you can do is to fork the source code and change that part of the code by yourself.
i've faced a similar problem, and by debuging cause i found the target website uses Brotli compress algorithm, but browsermob-proxy only supports GZip decompression and other 'encoding-content' type content will be automaticlly decompressd as base64 binary data, therefore the content text is either empty or unusable
how to solve this problem? I'm facing this promble too, and its Response headers has one field that is “content-encoding: br”。So Dose it use Brotli compress algorithm?
I have also encountered this problem. Can I seek help or how can I change the response to remove the br?
Yes, 'Br' stands for Brotli compress algorithm. If I remember it correctly there isn't an ideal workaround for this problem, the only thing you can do is to fork the source code and change that part of the code by yourself.
and by the way, this is an old library, the last update was 6 years ago, please consider other libraries such as https://github.com/mitmproxy/mitmproxy