Leonti
Leonti

Reputation: 10970

BrowserMob proxy and hosts file

I'm trying to use BrowserMob proxy to monitor requests sent by WebDriver(Selenium) browser.

I instantiate proxy with:

    server = new ProxyServer(localProxyPort);       
    server.start();

Then I create Firefox profile which would use this proxy:

    FirefoxProfile profile = new FirefoxProfile(); 

    profile.setPreference("network.proxy.type", 1);
    profile.setPreference("network.proxy.http", "localhost");
    profile.setPreference("network.proxy.http_port", localProxyPort);      

My problem is that I have a LOT of different host mapping in my 'hosts' file. BrowserMob proxy ignores system hosts file, and tries to resolve ips by itself.

There is a solution:

    server.remapHost("somehost.com", "127.0.0.1");

But I cant do it for every host. Is there a way to force proxy to use my system hosts mappings?

Thanks!

Leonti

Upvotes: 3

Views: 2588

Answers (1)

user2220762
user2220762

Reputation: 565

We can have several hosts re-mapping using the same function:

server.remapHost("somehost.com", "127.0.0.1");
server.remapHost("someotherhost.com", IP Address);

Upvotes: 2

Related Questions