[Mono-list] System.Net.CookieContainer adding inappropriate $Port attribute to cookies?

benanhalt ben.anhalt at gmail.com
Wed May 27 19:50:17 EDT 2009


According to RFC 2965 if the port attribute is absent from the Set-Cookie
header, it must also be absent from the corresponding Cookie request header. 
>From paragraph 3.3.4:

"...the port attribute MUST be present if the
Port attribute was present in the Set-Cookie2 header, and it MUST
have the same value, if any.  Otherwise, if the Port attribute was
absent from the Set-Cookie2 header, the attribute likewise MUST be
omitted from the Cookie request header."

The current behavior of System.Net.CookieContainer is such that when cookies
are added to the container, the method Cook(Uri uri, Cookie cookie)
unconditionally sets the attribute cookie.Port to uri.Port.ToString() unless
uri.IsDefaultPort.

This seems contrary to the RFC, but I'm no expert and perhaps this is the
expected behavior in most real applications.  I did run into some difficulty
with it in a context where the server was not expecting the $Port attribute
and rejected the cookies as invalid. So, I thought I would bring it up for
more knowledgeable folks to take a look at.

Thanks. 




-- 
View this message in context: http://www.nabble.com/System.Net.CookieContainer-adding-inappropriate-%24Port-attribute-to-cookies--tp23752882p23752882.html
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list