From: Ahmed A. <asa...@ya...> - 2017-03-30 23:07:25
|
Hi Wayne, The logic is in WebClient.loadWebResponseFromWebConnection(). I am afraid there is no currently way to exactly know, except by copying the method on your code and do the same checking. Hope that helps, Ahmed From: Wayne <way...@ho...> To: "Htm...@li..." <Htm...@li...> Sent: Thursday, March 30, 2017 8:14 PM Subject: [Htmlunit-user] how to get redirect chain Hi, I’m new to the alias and this may be an old topic. When I retrieve a page using htmlunit, there are usually some level of redirections. I would like to get the full redirection chain. One suggestion is the overwrite the HttpWebConnection. However, all I have is a WebRequest and WebResponse. public WebResponse getResponse(WebRequest request) throws IOException { super(request); } I have 2 problems: 1. It’s hard for me to tell if the web request is the original entry page. Or is it from loading a resource in the middle of parsing a non-entry page. I’m missing the “enclosed page” that triggered the http connection. 2. In the response, I could try to parse and get the href. But I wonder if the redirect response is not well formatted, how do I guarantee the href I got is the page the parse is going to visit. Wonder if anybody has been successful in retrieving the redirect chain. Thanks a lot. -Wayne ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Htmlunit-user mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/htmlunit-user |