2012-11-27 43 views
2

我試圖使用BrowserMob proxy來監視由WebDriver(Selenium)瀏覽器發送的請求。BrowserMob代理和主機文件

我實例代理有:

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

然後,我創建這將使用這個代理的Firefox配置文件:

FirefoxProfile profile = new FirefoxProfile(); 

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

我的問題是,我有不同的主機映射了很多我「主人'文件。 BrowserMob代理忽略系統主機文件,並嘗試自行解析ips。

有一個解決方案:

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

,但我不能這樣做對每一臺主機。有沒有辦法強制代理使用我的系統主機映射?

謝謝!

Leonti

回答

1

我們可以有多個主機使用相同的功能重新映射:

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

我知道,我的意思是「我不能爲每個主機做」是我有(有:) :)太多的映射把他們的每一個在.remapHost()函數。 – Leonti

+0

您可以自動將主機文件轉換爲remapHost配置行。 –