From: Toddy M. <zzz...@en...> - 2005-07-26 18:27:43
|
Hello Marc, I will open an RFE. Meanwhile you advise to do something like this? public HtmlPage submitRegistration(HtmlPage aPage) { ... WebClient aClient = aPage.getWebClient(); URL referer = aPage.getWebResponse().getUrl(); aClient.addRequestHeader("Referer", referer.toString()); HtmlPage nextPage = (HtmlPage)button.click(); } Btw.: I already advised to not rely on the Referer request-header field. Thx -Toddy Marc Guillemot wrote: > Hi, > > htmlunit doesn't currently set any Referer header. It's possible (but > tedious) to use WebClient#addRequestHeader before to click the link. > Please open a RFE for this. > > NB: except if your webapp is only for intranet use, it may be quite > unsecure to rely on the Referer header value. > > Marc. > > Toddy Marx wrote: > >> Hello, >> >> I would like to submit a form (post) with HtmlUnit having the >> Referer request-header field set. It works fine to submit the form >> but the referer-header field is not set. >> >> Is there a way to set the referer when submitting a form? >> >> Thanx! >> -Toddy >> >> My code looks like this: >> >> public HtmlPage submitRegistration(HtmlPage aPage) { >> // get the form to process it >> HtmlForm regForm = aPage.getFormByName("registration"); >> >> // get the submit button to later click it >> HtmlSubmitInput button = >> (HtmlSubmitInput)regForm.getInputByValue("register"); >> // get the textfield to enter the name >> HtmlTextInput textField = >> (HtmlTextInput)regForm.getInputByName("name"); >> >> String nameString = "Homer"; >> textField.setValueAttribute(nameString); >> >> // submit the form and get the response page >> HtmlPage nextPage = (HtmlPage)button.click(); >> >> return nextPage; >> } >> >> >> >> >> >> >> >> >> ------------------------------------------------------- >> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies >> from IBM. Find simple to follow Roadmaps, straightforward articles, >> informative Webcasts and more! Get everything you need to get up to >> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click >> _______________________________________________ >> Htmlunit-user mailing list >> Htm...@li... >> https://lists.sourceforge.net/lists/listinfo/htmlunit-user >> > > > > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > from IBM. Find simple to follow Roadmaps, straightforward articles, > informative Webcasts and more! Get everything you need to get up to > speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > |