From: Mike P. <mpo...@do...> - 2011-08-27 14:37:17
|
I found instructions for the HttpClient that allowed the user to provide a different TCP socket factory implementation. My understanding is that the class API takes in the host name and provides a socket connected or to connect to that host. What I could not figure out how to do is provide HtmlUnit my own HttpClient. Will the header method handle cookies correctly? On 08/24/2011 02:56 PM, Ahmed Ashour wrote: > Hi Mike, > > You need to programatically override DNS lookup, which is not possible > AFAIHK. > > You ideally should use 127.0.0.1, unless your web server needs the > "host" to work correctly. > > A workaround is to specify URL as "http://localhost", but explicitly > setting "Host" header to the hostname, so the actual connection goes > locally, but the web server detects the Host from the header. > > Hope that helps, > Ahmed > ---- > Blog: http://asashour.blogspot.com > ------------------------------------------------------------------------ > *From:* Mike Power <mpo...@do...> > *To:* htm...@li... > *Sent:* Wednesday, August 24, 2011 5:09 AM > *Subject:* [Htmlunit-user] Using a domain name to connect to server > running on 127.0.0.1 > > I need to connect to my server using a domain name something like > localhost.corp.com. However the server I am trying to connected to is > an internal web server I spawned on this host. So it is actually > running on address 127.0.0.1 and some randomly selected port. Since > I'll be running multiple tests at the same time on the same host I need > to be able to tell the webClient to connect a specific domain name to a > specific ip address (127.0.0.1). So that the web application will > behave correctly. I probably won't be able to use /etc/hosts since this > machine will be used by multiple groups and such configuration may not > be under my control. > > final WebClient webClient = new WebClient(); > //???? > final HtmlPage page = webClient.getPage("http://localhost.corp.com"); > > Mike Power > > > > ------------------------------------------------------------------------------ > EMC VNX: the world's simplest storage, starting under $10K > The only unified storage solution that offers unified management > Up to 160% more powerful than alternatives and 25% more efficient. > Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > <mailto:Htm...@li...> > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > > > ------------------------------------------------------------------------------ > EMC VNX: the world's simplest storage, starting under $10K > The only unified storage solution that offers unified management > Up to 160% more powerful than alternatives and 25% more efficient. > Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev > > > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user |