/// <exception cref="Sharpen.CloneNotSupportedException"></exception>
 public override object Clone()
 {
     Apache.Http.Impl.Cookie.BasicClientCookie2 clone = (Apache.Http.Impl.Cookie.BasicClientCookie2
                                                         )base.Clone();
     if (this.ports != null)
     {
         clone.ports = this.ports.Clone();
     }
     return(clone);
 }
        /// <exception cref="Apache.Http.Cookie.MalformedCookieException"></exception>
        private IList <Apache.Http.Cookie.Cookie> CreateCookies(HeaderElement[] elems, CookieOrigin
                                                                origin)
        {
            IList <Apache.Http.Cookie.Cookie> cookies = new AList <Apache.Http.Cookie.Cookie>(elems
                                                                                              .Length);

            foreach (HeaderElement headerelement in elems)
            {
                string name  = headerelement.GetName();
                string value = headerelement.GetValue();
                if (name == null || name.Length == 0)
                {
                    throw new MalformedCookieException("Cookie name may not be empty");
                }
                BasicClientCookie2 cookie = new BasicClientCookie2(name, value);
                cookie.SetPath(GetDefaultPath(origin));
                cookie.SetDomain(GetDefaultDomain(origin));
                cookie.SetPorts(new int[] { origin.GetPort() });
                // cycle through the parameters
                NameValuePair[] attribs = headerelement.GetParameters();
                // Eliminate duplicate attributes. The first occurrence takes precedence
                // See RFC2965: 3.2  Origin Server Role
                IDictionary <string, NameValuePair> attribmap = new Dictionary <string, NameValuePair
                                                                                >(attribs.Length);
                for (int j = attribs.Length - 1; j >= 0; j--)
                {
                    NameValuePair param = attribs[j];
                    attribmap.Put(param.GetName().ToLower(Sharpen.Extensions.GetEnglishCulture()), param
                                  );
                }
                foreach (KeyValuePair <string, NameValuePair> entry in attribmap.EntrySet())
                {
                    NameValuePair attrib = entry.Value;
                    string        s      = attrib.GetName().ToLower(Sharpen.Extensions.GetEnglishCulture());
                    cookie.SetAttribute(s, attrib.GetValue());
                    CookieAttributeHandler handler = FindAttribHandler(s);
                    if (handler != null)
                    {
                        handler.Parse(cookie, attrib.GetValue());
                    }
                }
                cookies.AddItem(cookie);
            }
            return(cookies);
        }