Interceptors doesn't work on localhost

801 views
Skip to first unread message

Julien HENRY

unread,
Sep 21, 2011, 5:38:58 AM9/21/11
to BrowserMob Proxy
Hi,

I'm using BrowserMob with Selenium2 to perform tests of my web site.
This is a completely automated setup: the site is started with Jetty
on localhost.
I'm trying to use BrowserMob to retrieve HTTP response status code/
response raw body so I set a response interceptor:
proxyServer.addResponseInterceptor(new
HttpResponseInterceptor() {
public void process(HttpResponse response,
HttpContext context) throws HttpException, IOException {
//Extract useful infos from response
}
});

But it doesn't work, the interceptor is never called. After looking at
the code it seems it is because of this part of code in
BrowserMobProxyHandler:
// We don't want localhost or selenium-related showing up
in the detailed transaction logs
if (urlStr.startsWith("http://localhost") ||
urlStr.contains("/selenium-server/")) {
return super.proxyPlainTextRequest(url, pathInContext,
pathParams, request, response);
}

As a result all my traffic is handled by SeleniumProxyHandler that
does not honor interceptors.

Is there any solution for my problem?

Thanks

Patrick Lightbody

unread,
Sep 30, 2011, 6:00:00 AM9/30/11
to browserm...@googlegroups.com
I think we could probably just get rid of that block. Can you submit a patch and/or open a bug?

Paul Wellner Bou

unread,
Jun 12, 2012, 9:25:18 AM6/12/12
to browserm...@googlegroups.com

Patrick Lightbody

unread,
Jun 13, 2012, 1:59:57 AM6/13/12
to browserm...@googlegroups.com
Paul,
You're probably right that lines 144-146 are the problem. Any chance you can remove them and do a local build and confirm it fixes your issue?

Tarun Kumar

unread,
Sep 24, 2012, 6:41:45 AM9/24/12
to browserm...@googlegroups.com
I have not had chance to test it locally but seems that there is a pull request against it - https://github.com/webmetrics/browsermob-proxy/pull/60
I would try to make a build locally this week and post my observations here.

Patrick Lightbody

unread,
Sep 26, 2012, 12:52:57 AM9/26/12
to browserm...@googlegroups.com
Hey everyone - sorry for being a bit slow to all this. Still recovering from the move from San Diego to Portland, the new job, and of course the 1 year old baby :) Hope to put out a new release of BMP soon!
Message has been deleted

Tarun Kumar

unread,
Sep 26, 2012, 5:15:06 AM9/26/12
to browserm...@googlegroups.com
I git cloned the browser mob proxy repo, followed pull request - https://github.com/webmetrics/browsermob-proxy/pull/60/files , packaged the new jar file and tried BMP to capture local traffic.
My site runs on - "localhost:8084"
But it seems that localhost does not proxy through and my application did not open in firefox browser.
Googled, and found that I can use "localhost.:8084" to fool system. (Did you notice 'dot' after word - 'localhost' ?)
And voila, BMP started intercepting the traffic and I got traffic information in har file.

but there are few caveats -

1. I don't see the application css being loaded
2. Clicks don't work on some elements. Though I don't this issue if I don't use BMP

Patirk, is the any other test I should do? And tons of thanks for building BMP. 

~ tarun

Tarun Kumar

unread,
Sep 26, 2012, 6:42:26 AM9/26/12
to browserm...@googlegroups.com
I noticed that it is not only localhost but any URL (like - http://wikipedia/org) I access while starting proxy from the updated jar the css is not loaded.
This also causes issues on an ajaxified page and does not bring up the elements which other wise works perfect when not using BMP.
I am uploading updated jar file in this thred.
  
browsermob-proxy-2.0-beta-7-SNAPSHOT.jar

Patrick Lightbody

unread,
Oct 15, 2012, 12:56:04 AM10/15/12
to browserm...@googlegroups.com
I don't know why you wouldn't get images loading for other sites. That's pretty basic stuff that BMP has been really well tested for.
Reply all
Reply to author
Forward
0 new messages