webmetrics / browsermob-proxy

NOTICE: this project has been forked and is being maintained at https://github.com/lightbody/browsermob-proxy
https://github.com/lightbody/browsermob-proxy
Apache License 2.0
234 stars 773 forks source link

DNS lookup for localhost fails on Linux #63

Open da-terry opened 12 years ago

da-terry commented 12 years ago

When using "localhost" (after removing the proxy restriction), Lookup tries to do a DNS A lookup using the search domain from resolv.conf, which will fail in most cases for obvious reasons. It seems to ignore /etc/hosts as a first lookup step.

Trying to use 127.0.0.1 instead fails as well, since HTTPClient does a reverse lookup and sends "localhost" again to BrowserMobHostNameResolver.

The only workaround I've found is to use a remap rule, like so:

proxy.start() proxy.remapHost("localhost", "127.0.0.1")

This bypasses the broken DNS lookup.