browsermob-proxy icon indicating copy to clipboard operation
browsermob-proxy copied to clipboard

Browsermob-proxy does not add custom request header

Open Illakkiya opened this issue 3 years ago • 1 comments

Using browsermob proxy 2.1.5 with Selenium (3.14.0) Java code I'm trying to add a custom header to Chrome browser but the request header is not getting added to all requests

Sample code:

       BrowserMobProxy proxy = new BrowserMobProxyServer();
        proxy.addHeader("testGroup1" , "*****");
        proxy.start(0);
        Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
        String proxyOption = "--proxy-server=" + seleniumProxy.getHttpProxy();
        chromeOptions.addArguments(proxyOption);

Also tried like the following,

        proxy.addRequestFilter((request, contents, messageInfo) -> {
            request.headers().add("testGroup1" , "*****");
            return null;
        });
        String proxyOption = "--proxy-server=" + seleniumProxy.getHttpProxy();
        chromeOptions.addArguments(proxyOption);

Illakkiya avatar Feb 09 '22 20:02 Illakkiya

same here, the request are captured, but not altered, so I can log the request.getUri() but the headers().add() doesn't do anything to the actual request... ¯_(ツ)_/¯

Wimpje avatar Jun 30 '22 14:06 Wimpje