add auxiliar httpresponse.Redirect(string url, [HttpStatusCode redirStatusCode = HttpStatusCode.Redirect])

This commit is contained in:
UbitUmarov
2021-12-20 11:07:26 +00:00
parent 112a86b9e0
commit 3f584dbf12
10 changed files with 58 additions and 23 deletions

View File

@@ -191,10 +191,24 @@ namespace OSHttpServer
get { return m_cookies; }
}
/// <summary>
/// Set response as a http redirect
/// </summary>
/// <param name="url">redirection target url</param>
/// <param name="redirStatusCode">the response Status, must be Found, Redirect, Moved,MovedPermanently,RedirectKeepVerb, RedirectMethod, TemporaryRedirect. Defaults to Redirect</param>
public void Redirect(string url, HttpStatusCode redirStatusCode = HttpStatusCode.Redirect)
{
if (HeadersSent)
throw new InvalidOperationException("Headers have already been sent.");
m_headers["Location"] = url;
Status = redirStatusCode;
}
/// <summary>
/// Add another header to the document.
/// </summary>
/// <param name="name">Name of the header, case sensitive, use lower cases.</param>
/// <param name="name">Name of the header, case sensitive.</param>
/// <param name="value">Header values can span over multiple lines as long as each line starts with a white space. New line chars should be \r\n</param>
/// <exception cref="InvalidOperationException">If headers already been sent.</exception>
/// <exception cref="ArgumentException">If value conditions have not been met.</exception>