From: Brad C. <yo...@br...> - 2004-12-10 20:17:00
|
I recently had to refactor DefaultPageCreator to make easier to handle unknown content types that are really html pages. All you need to do is extend DefaultPageCreator and override the createPage() method to do what you want. If you always have html pages returned then just take out all the logic and always make an HtmlPage: http://htmlunit.sourceforge.net/xref/com/gargoylesoftware/htmlunit/DefaultPageCreator.html#73 Brad C --- "Erskine, Chris" <chr...@ed...> wrote: > Jean-Rene, > > Are you actually setting the response type? I have found that at times, you > have to set the expected response type which is done with code, not the META > tag. > > Chris Erskine > > EDS Consulting Services > F5-EDS-001 > 2424 Garden of the Gods Rd > Colorado Springs, CO 80919 > > Phone: 719-535-6064 > > > > -----Original Message----- > > From: htm...@li... [mailto:htmlunit-user- > > ad...@li...] On Behalf Of Rousseau, Jean Rene > > Sent: Friday, December 10, 2004 12:48 PM > > To: 'htm...@li...' > > Subject: RE: [Htmlunit-user] Re: Problems handling with the Content-Type i > > s specified using ME TA tags? > > > > everything works perfectly fine with a regular browser. Actually this > > application is in production in several of our customers. It works fine > > also > > with JWebUnit(HttpUnit). > > > > One of the difference between the working pages and the non-working pages > > is > > that the non-working pages go through a ServletFilter before being > > produced. > > In Both cases, a Servlet handles the request, produced XML that is then > > transformed by an XSL stylesheet. > > > > I'll re-try with the proposed loggers > > > > thanks, > > > > Jean-Rene > > > > > -----Original Message----- > > > From: Marc Guillemot [mailto:mgu...@ya...] > > > Sent: Friday, December 10, 2004 2:42 PM > > > To: htm...@li... > > > Subject: Re: [Htmlunit-user] Re: Problems handling with the > > > Content-Type > > > is specified using ME TA tags? > > > > > > > > > Jean Rene, > > > > > > you can set log level to debug for > > > > > > logger.httpclient.wire > > > httpclient.wire.header > > > httpclient.wire.content > > > > > > and you will really get more information. > > > > > > Are some of the pages you have problem with available on the internet? > > > > > > Marc. > > > > > > Rousseau, Jean Rene wrote: > > > > I'm so confused with this problem... > > > > > > > > Here are my logs when it works > > > > > > > > Content type is: text/html > > > > Content stream is: > > > > <html > > > xmlns:translator="com.banctec.pca.pub.PublicLanguageTranslatorUtil" > > > > xmlns:java="java"> > > > > <head> > > > > <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> > > > > (...) > > > > > > > > Here is when it doesn't work: > > > > > > > > Content type is: > > > > Content Stream is: > > > > <html > > > xmlns:translator="com.banctec.pca.pub.PublicLanguageTranslatorUtil" > > > > xmlns:java="java"> > > > > <head> > > > > <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> > > > > (...) > > > > > > > > We clearly see that webResponde.getContentType() returns > > > null !! but why > > > > !?!?!? response content stream is the same as the correct output. > > > > > > > > So how is it possible that my content-type is null in > > > certain pages ? > > > > > > > > > > > >>-----Original Message----- > > > >>From: David D.Kilzer [mailto:ddk...@ki...] > > > >>Sent: Friday, December 10, 2004 11:40 AM > > > >>To: htm...@li... > > > >>Subject: Re: [Htmlunit-user] Re: Problems handling with the > > > >>Content-Type > > > >>i s specified using ME TA tags? > > > >> > > > >> > > > >>What "Content-Type:" header is your web server sending back > > > for this > > > >>page? (If you're using Mozilla or Firefox, you can do a > > > "Get Info" > > > >>once the page is loaded to find out, or use a packet sniffer like > > > >>Ethereal to capture the headers "on the wire".) > > > >> > > > >>In htmlunit-1.3, the DefaultPageCreator.createPage() method > > > is where > > > >>the decision is made on what type of page to create. > > > >>Apparently, this > > > >>page is causing all of the if/else logic to fall through to > > > >>create an > > > >>UnexpectedPage object. > > > >> > > > >>Dave > > > >> > > > >> > > > >>On Dec 10, 2004, at 9:16 AM, Rousseau, Jean Rene wrote: > > > >> > > > >> > > > >>>Hi, > > > >>> > > > >>>Here is more info about my problem. I'm really confused, > > > >> > > > >>because I have > > > >> > > > >>>similar headers in other pages and they work ok !!. > > > >>> > > > >>>Any ideas ? > > > >>> > > > >>> > > > >>>code: > > > >>> > > > >>> URL url = new > > > >> > > > >>URL(state.getBaseUrl()+"/html/admin/home_en.html"); > > > >> > > > >>> HtmlPage page = null; > > > >>> page = (HtmlPage)state.getWebClient().getPage(url); > > > >>> HtmlForm form = page.getFormByName("login"); > > > >>> > > > >>> > > > >> > > > >>form.getInputByName("userid").setValueAttribute(cells.more.tex > > > >>t().toUpp > > > >> > > > >>>erCase()); > > > >>> > > > >>> > > > >> > > > >>form.getInputByName("password").setValueAttribute(cells.more.m > > > > > > > > ore.text( > > > > > > > >>>).toUpperCase()); > > > >>> > > > >>> Page p = form.submit(); > > > >>> System.out.println(p); > > > >>> System.out.println(p.getWebResponse().getContentAsString()); > > > >>> state.setCurrentPage((HtmlPage)form.submit()); > > > >>> > > > >>>This gives me a ClassCastException because the response page is an > > > >>>UnexcpectedPage. > > > >>> > > > >>>output: > > > >>> > > > >>>com.gargoylesoftware.htmlunit.UnexpectedPage@302e67 > > > >>> > > > >>><html > > > >>> > > > >> > > > >>xmlns:translator="com.banctec.pca.pub.PublicLanguageTranslat > > > orUtil" > > > >> > > > >>>xmlns:java="java"> > > > >>><head> > > > >>><META http-equiv="Content-Type" content="text/html; > > > >>>charset=ISO-8859-1"> > > > >>><link href="/pca/stylesheets/pcaadmin.css" type="text/css" > > > >>>rel="stylesheet"> > > > >>><title>PCA Admin: Users List</title> > > > >>></head> > > > >>>(...) > > > >> > > > >> > > > >> > > > >>------------------------------------------------------- > > > >>SF email is sponsored by - The IT Product Guide > > > >>Read honest & candid reviews on hundreds of IT Products from > > > >>real users. > > > >>Discover which products truly live up to the hype. Start > > > reading now. > > > >>http://productguide.itmanagersjournal.com/ > > > >>_______________________________________________ > > > >>Htmlunit-user mailing list > > > >>Htm...@li... > > > >>https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > > >> > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > SF email is sponsored by - The IT Product Guide > > > > Read honest & candid reviews on hundreds of IT Products > > > from real users. > > > > Discover which products truly live up to the hype. Start > > > reading now. > > > > http://productguide.itmanagersjournal.com/ > > > > _______________________________________________ > > > > Htmlunit-user mailing list > > > > Htm...@li... > > > > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > SF email is sponsored by - The IT Product Guide > > > Read honest & candid reviews on hundreds of IT Products from > > > real users. > > > Discover which products truly live up to the hype. Start reading now. > > > http://productguide.itmanagersjournal.com/ > > > _______________________________________________ > > > Htmlunit-user mailing list > > > Htm...@li... > > > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > > > > > > > > ------------------------------------------------------- > > SF email is sponsored by - The IT Product Guide > > Read honest & candid reviews on hundreds of IT Products from real users. > > Discover which products truly live up to the hype. Start reading now. > > http://productguide.itmanagersjournal.com/ > > _______________________________________________ > > Htmlunit-user mailing list > > Htm...@li... > > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://productguide.itmanagersjournal.com/ > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > |