using System;
using System.Web;
namespace OSHttpServer
{
///
/// cookie sent by the client/browser
///
///
public class RequestCookie
{
private readonly string _name = null;
private string _value = null;
///
/// Constructor.
///
/// cookie identifier
/// cookie content
/// id or content is null
/// id is empty
public RequestCookie(string id, string content)
{
if (string.IsNullOrEmpty(id)) throw new ArgumentNullException("id");
if (content == null) throw new ArgumentNullException("content");
_name = id;
_value = content;
}
#region inherited methods
///
/// Gets the cookie HTML representation.
///
/// cookie string
public override string ToString()
{
return string.Format("{0}={1}; ", HttpUtility.UrlEncode(_name), HttpUtility.UrlEncode(_value));
}
#endregion
#region public properties
///
/// Gets the cookie identifier.
///
public string Name
{
get { return _name; }
}
///
/// Cookie value. Set to null to remove cookie.
///
public string Value
{
get { return _value; }
set
{
_value = value;
}
}
#endregion
}
}