From: Ahmed A. <asa...@ya...> - 2017-03-31 11:28:34
|
Hi Wayne, Check RefreshHandler, and HtmlPage.executeRefreshIfNeeded() I guess it would be easier for you to use the following workaround: new Exception().getStackTrace() And then see which StackTraceElement suits your need, e.g. is it called from Window.setLocation, or from somewhere else? Ahmed From: Wayne <way...@ho...> To: Ahmed Ashour <asa...@ya...>; "Htm...@li..." <htm...@li...> Sent: Friday, March 31, 2017 7:31 AM Subject: Re: [Htmlunit-user] how to get redirect chain #yiv7655422312 #yiv7655422312 -- _filtered #yiv7655422312 {font-family:Arial;panose-1:2 11 6 4 2 2 2 2 2 4;} _filtered #yiv7655422312 {panose-1:2 4 5 3 5 4 6 3 2 4;} _filtered #yiv7655422312 {font-family:DengXian;panose-1:2 1 6 0 3 1 1 1 1 1;} _filtered #yiv7655422312 {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;} _filtered #yiv7655422312 {panose-1:2 0 5 3 0 0 0 2 0 4;}#yiv7655422312 #yiv7655422312 p.yiv7655422312MsoNormal, #yiv7655422312 li.yiv7655422312MsoNormal, #yiv7655422312 div.yiv7655422312MsoNormal {margin:0in;margin-bottom:.0001pt;font-size:12.0pt;}#yiv7655422312 a:link, #yiv7655422312 span.yiv7655422312MsoHyperlink {color:blue;text-decoration:underline;}#yiv7655422312 a:visited, #yiv7655422312 span.yiv7655422312MsoHyperlinkFollowed {color:purple;text-decoration:underline;}#yiv7655422312 span.yiv7655422312EmailStyle17 {font-family:Calibri;color:windowtext;}#yiv7655422312 span.yiv7655422312msoIns {text-decoration:underline;color:teal;}#yiv7655422312 .yiv7655422312MsoChpDefault {font-size:10.0pt;} _filtered #yiv7655422312 {margin:1.0in 1.0in 1.0in 1.0in;}#yiv7655422312 div.yiv7655422312WordSection1 {}#yiv7655422312 Thank you very much Ahmed. Reading the loadWebResponseFromWebConnection() was helpful. That seems to only show the 30X redirection. I wonder where I find <meta http-equiv=”refresh…”/> redirect and javascript redirect (window.location). -Wayne From: Ahmed Ashour <asa...@ya...> Reply-To: Ahmed Ashour <asa...@ya...>, "Htm...@li..." <htm...@li...> Date: Thursday, March 30, 2017 at 4:04 PM To: "Htm...@li..." <htm...@li...> Subject: Re: [Htmlunit-user] how to get redirect chain 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 ------------------------------------------------------------------------------ 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 ------------------------------------------------------------------------------ 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 |