Example #1
0
        /*
         * Construct set-cookie header
         */
        internal HttpResponseHeader GetSetCookieHeader(HttpContext context)
        {
            StringBuilder s = new StringBuilder();

            // cookiename=
            if (!String.IsNullOrEmpty(_name))
            {
                s.Append(_name);
                s.Append('=');
            }

            // key=value&...
            if (_multiValue != null)
            {
                s.Append(_multiValue.ToString(false));
            }
            else if (_stringValue != null)
            {
                s.Append(_stringValue);
            }

            // domain
            if (!String.IsNullOrEmpty(_domain))
            {
                s.Append("; domain=");
                s.Append(_domain);
            }

            // expiration
            if (_expirationSet && _expires != DateTime.MinValue)
            {
                s.Append("; expires=");
                s.Append(HttpUtility.FormatHttpCookieDateTime(_expires));
            }

            // path
            if (!String.IsNullOrEmpty(_path))
            {
                s.Append("; path=");
                s.Append(_path);
            }

            // secure
            if (_secure)
            {
                s.Append("; secure");
            }

            // httponly, Note: IE5 on the Mac doesn't support this
            if (_httpOnly && SupportsHttpOnly(context))
            {
                s.Append("; HttpOnly");
            }

            // return as HttpResponseHeader
            return(new HttpResponseHeader(HttpWorkerRequest.HeaderSetCookie, s.ToString()));
        }
Example #2
0
        /*
         * Construct set-cookie header
         */
        internal HttpResponseHeader GetSetCookieHeader()
        {
            StringBuilder s = new StringBuilder();

            // cookiename=
            if (_name != null && _name.Length > 0)
            {
                s.Append(_name);
                s.Append('=');
            }

            // key=value&...
            if (_multiValue != null)
            {
                s.Append(_multiValue.ToString(false));
            }
            else if (_stringValue != null)
            {
                s.Append(_stringValue);
            }

            // domain
            if (_domain != null && _domain.Length > 0)
            {
                s.Append("; domain=");
                s.Append(_domain);
            }

            // expiration
            if (_expirationSet && _expires != DateTime.MinValue)
            {
                s.Append("; expires=");
                s.Append(HttpUtility.FormatHttpCookieDateTime(_expires));
            }

            // path
            if (_path != null && _path.Length > 0)
            {
                s.Append("; path=");
                s.Append(_path);
            }

            // secure
            if (_secure)
            {
                s.Append("; secure");
            }

            // return as HttpResponseHeader
            return(new HttpResponseHeader(HttpWorkerRequest.HeaderSetCookie, s.ToString()));
        }
Example #3
0
        internal HttpResponseHeader GetSetCookieHeader(HttpContext context)
        {
            StringBuilder builder = new StringBuilder();

            if (!string.IsNullOrEmpty(this._name))
            {
                builder.Append(this._name);
                builder.Append('=');
            }
            if (this._multiValue != null)
            {
                builder.Append(this._multiValue.ToString(false));
            }
            else if (this._stringValue != null)
            {
                builder.Append(this._stringValue);
            }
            if (!string.IsNullOrEmpty(this._domain))
            {
                builder.Append("; domain=");
                builder.Append(this._domain);
            }
            if (this._expirationSet && (this._expires != DateTime.MinValue))
            {
                builder.Append("; expires=");
                builder.Append(HttpUtility.FormatHttpCookieDateTime(this._expires));
            }
            if (!string.IsNullOrEmpty(this._path))
            {
                builder.Append("; path=");
                builder.Append(this._path);
            }
            if (this._secure)
            {
                builder.Append("; secure");
            }
            if (this._httpOnly && this.SupportsHttpOnly(context))
            {
                builder.Append("; HttpOnly");
            }
            return(new HttpResponseHeader(0x1b, builder.ToString()));
        }