HtmlUnit doubts regarding cookies and windows

China☆狼群 提交于 2019-12-23 05:32:50

问题


If the HtmlUnit stores cookies in memory then Will HtmlUnit respond the server with cookies?

When the HtmlUnit session terminates? Will it terminate when i call webclient.closeWindow()?

As acc. to the HtmlUnit docs, WebClient represents a browser, so Is it represent a mutiple-windows browser (like IE7 in which we can open multiple tabs) or represen a single-window browser?

If it represents a multiple-window browser, then does the HttpSession is maintained accross multiple windows of that webclient like real browsers?


回答1:


Not a real answer, but some hints.

If the HtmlUnit stores cookies in memory then Will HtmlUnit respond the server with cookies?

HtmlUnit's cookie policy is to be browser-compatible so I would expect it to do so.

When the HtmlUnit session terminates? Will it terminate when i call webclient.closeWindow()?

I'm not sure about this one. Did you try to test or debug this? Did you look at the source code? Actually, I wonder what should be the expected behavior here.

As acc. to the HtmlUnit docs, WebClient represents a browser, so does it represent a mutiple-windows browser (like IE7 in which we can open multiple tabs) or a single-window browser?

I consider that WebClient represents a single tabbed browser.

If it represents a multiple-window browser, then does the HttpSession is maintained accross multiple windows of that webclient like real browsers?

Note that this behavior is not consistent between browsers and between browser versions: IE6, IE7, IE8, Firefox, Chrome, they all behave (more or less) differently (see Cookies in Firefox and Internet Explorer, or Browsers, processes, cookies and session state, or Session Cookies, sessionStorage, and IE8). So I wouldn't consider that there is a general rule with "real" browsers.

Actually, I think that your best weapons are the source code and your debugger. These questions would be easy to verify IMO.



来源:https://stackoverflow.com/questions/2081260/htmlunit-doubts-regarding-cookies-and-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!