使用的HttpWebRequest / HttpWebResponse和饼干的问题饼干、问题、HttpWebRequest、HttpWebResponse

2023-09-03 03:48:06 作者:拥冇伱旳温柔

我有麻烦与HttpWebRequest的/ HttpWebResponse和饼干/的CookieContainer / CookieCollection。 问题是,如果web服务器不发送/ cookie中使用路径,Cookie.Path等于/请求URI的路径一部分,而不是或为空在我的应用程序。 因此,这些cookies不为全域,它实际上没有在正确的Web浏览器。 任何想法如何解决这个问题呢?

I'm having troubles with HttpWebRequest/HttpWebResponse and cookies/CookieContainer/CookieCollection. The thing is, if the web server does not send/use a "path" in the cookie, Cookie.Path equals the path-part of the request URI instead of "/" or being empty in my application. Therefore, those cookies do not work for the whole domain, which it actually does in proper web browsers. Any ideas how to solve this issue?

在此先感谢

推荐答案

嗯,我明白你的意思。一般是什么浏览器的真正的做的是将含有该文件的路径中的文件夹;对于/login.php这将是'/',所以这将有效地在整个领域的工作。 '/potato/login.php'将限于'/马铃薯/';与尾随路径信息任何部分(如/login.php/)将无法正常工作。

Ah, I see what you mean. Generally what browsers really do is take the folder containing the document as the path; for ‘/login.php’ that would be ‘/’ so it would effectively work across the whole domain. ‘/potato/login.php’ would be limited to ‘/potato/’; anything with trailing path-info parts (eg. ‘/login.php/’) would not work.

在这种情况下,网景规范可你究竟怎么读路径也被认为是错误的或至少是误导性的,声称该路径默认为当前文件路径...根据。然而,浏览器行为是一致追溯到原始的Netscape版本。网景从未被认为擅长写作规范...

In this case the Netscape spec could be considered wrong or at least misleading in claiming that path defaults to the current document path... depending on how exactly you read ‘path’ there. However the browser behaviour is consistent back as far as the original Netscape version. Netscape never were that good at writing specs...

如果.NET的HttpWebRequest的是真的违约CookieContainer.Path到的全部的当前文档的路径,我会提交一个bug反对。

If .NET's HttpWebRequest is really defaulting CookieContainer.Path to the entire path of the current document, I'd file a bug against it.

不幸的是,现实世界的行为是不实际当前在标准文献中描述...有RFC 2965,这确实得到正确的路径的事,但使其他一些变化不会重新真实的浏览器的presentative行为,所以这不是完全可靠的要么。 : - (

Unfortunately the real-world behaviour is not actually currently described in a standards document... there is RFC 2965, which does get the path thing right, but makes several other changes not representative of real-world browser behaviour, so that's not wholly reliable either. :-(

 
精彩推荐
图片推荐