Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: dea6157026
Fetching contributors…

Cannot retrieve contributors at this time

69 lines (58 sloc) 1.869 kB
using System;
using System.Web;
namespace HttpServer.Messages
{
/// <summary>
/// cookie sent by the client/browser
/// </summary>
/// <seealso cref="ResponseCookie"/>
public class RequestCookie
{
private readonly string _name;
private string _value;
/// <summary>
/// Constructor.
/// </summary>
/// <param name="id">cookie identifier</param>
/// <param name="content">cookie content</param>
/// <exception cref="ArgumentNullException">id or content is null</exception>
/// <exception cref="ArgumentException">id is empty</exception>
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
/// <summary>
/// Gets the cookie HTML representation.
/// </summary>
/// <returns>cookie string</returns>
public override string ToString()
{
return string.Format("{0}={1}; ", HttpUtility.UrlEncode(_name), HttpUtility.UrlEncode(_value));
}
#endregion
#region public properties
/// <summary>
/// Gets the cookie identifier.
/// </summary>
public string Name
{
get { return _name; }
}
/// <summary>
/// Gets value.
/// </summary>
/// <remarks>
/// Set to <c>null</c> to remove cookie.
/// </remarks>
public string Value
{
get { return _value; }
set { _value = value; }
}
#endregion
}
}
Jump to Line
Something went wrong with that request. Please try again.