}
set
{
- m_port_implicit = false;
if (string.IsNullOrEmpty(value))
{
// "Port" is present but has no value.
+ // Therefore; the effective port value is implicit.
+ m_port_implicit = true;
m_port = string.Empty;
}
else
{
+ // "Port" value is present, so we use the provided value rather than an implicit one.
+ m_port_implicit = false;
// Parse port list
if (!value.StartsWith('\"') || !value.EndsWith('\"'))
{
c.Version = 0;
Assert.Equal("name=value; $Path=path; $Domain=domain; $Port=\"80\"", c.ToString());
+ // If a cookie string specifies either an empty string or no value for the port, then the port should be considered implicit.
+ // Otherwise such cookies will have no valid ports and also be incapable of assuming a usable port which in turn means they cannot be matched to ANY Uris and will effectively become nonfunctional.
c.Port = "";
- Assert.Equal("name=value; $Path=path; $Domain=domain; $Port", c.ToString());
+ Assert.Equal("name=value; $Path=path; $Domain=domain", c.ToString());
+
+ // Test null also, for sanity.
+ c.Port = null;
+ Assert.Equal("name=value; $Path=path; $Domain=domain", c.ToString());
}
}
}