/// <summary>
/// Automatically sends the appropriate response to the user agent.
/// </summary>
/// <param name="response">The response to set to this message.</param>
public virtual void Send(HttpListenerResponse response) {
Requires.NotNull(response, "response");
response.StatusCode = (int)this.Status;
MessagingUtilities.ApplyHeadersToResponse(this.Headers, response);
foreach (HttpCookie httpCookie in this.Cookies) {
var cookie = new Cookie(httpCookie.Name, httpCookie.Value) {
Expires = httpCookie.Expires,
Path = httpCookie.Path,
HttpOnly = httpCookie.HttpOnly,
Secure = httpCookie.Secure,
Domain = httpCookie.Domain,
};
response.AppendCookie(cookie);
}
if (this.ResponseStream != null) {
response.ContentLength64 = this.ResponseStream.Length;
this.ResponseStream.CopyTo(response.OutputStream);
}
response.OutputStream.Close();
}