HttpRequest
This class all informations of the client request.
Method
csharp
/// <summary>
/// Get the HTTP request method
/// </summary>
string Method { get; private set }Url
csharp
/// <summary>
/// Get the HTTP request URL
/// </summary>
string Url { get; private set }Protocol
csharp
/// <summary>
/// Get the HTTP request protocol version
/// </summary>
string Protocol { get; private set }Body
csharp
/// <summary>
/// Get the HTTP request body as string
/// </summary>
string Body { get; private set }BodyBytes
csharp
/// <summary>
/// Get the HTTP request body as byte array
/// </summary>
byte[] BodyBytes { get; private set }BodySpan
csharp
/// <summary>
/// Get the HTTP request body as byte span
/// </summary>
Span<byte> BodySpan { get; private set }BodyLength
csharp
/// <summary>
/// Get the HTTP request body length
/// </summary>
long BodyLength { get; private set }Cookies
csharp
/// <summary>
/// Get the HTTP request cookies count
/// </summary>
long Cookies { get; private set }Used to get the cookies count and iterate through Cookie()
Cookie()
csharp
/// <summary>
/// Get the HTTP request cookie by index
/// </summary>
(string, string) Cookie(int i)Header()
csharp
/// <summary>
/// Return Header Value for a specified header name for a Request
/// </summary>
/// <param name="name">The Header Name.</param>
/// <returns><c>string value</c> of the header if exists in the Request; otherwise, <c>null</c>.</returns>
public string Header(string name)This method return the string content of the header by its name.
BodyMap()
csharp
/// <summary>
/// Update the model with data from POST
/// </summary>
/// <param name="request">The HttpRequest request.</param>
/// <param name="model">The Model instance to populate.</param>
/// <param name="includeProperties">string array of properties to update the model. if null update all.</param>
/// <param name="excludeProperties">string array of properties to not update.</param>
/// <param name="jsonEngine">the json library to handle serialization/deserialization</param>
/// <returns><c>true</c> if operation success; otherwise, <c>false</c>.</returns>
public bool BodyMap<TModel>(this HttpRequest request, TModel model, IEnumerable<string> includeProperties = null, IEnumerable<string> excludeProperties = null, IJsonEngine jsonEngine = null)BodyMapAnonymous()
csharp
/// <summary>
/// Update the anonymous model with data from POST
/// </summary>
/// <param name="request">The HttpRequest request.</param>
/// <param name="model">The Anonymous Model instance to populate.</param>
/// <param name="jsonEngine">the json library to handle serialization/deserialization</param>
/// <returns><c>true</c> if operation success; otherwise, <c>false</c>.</returns>
public bool BodyMapAnonymous<TModel>(this HttpRequest request, ref TModel model, IJsonEngine jsonEngine = null)BodyFile()
csharp
/// <summary>
/// Parses multipart/form-data and contentType given the request body (Request.InputStream)
/// Please note the underlying input stream is not rewindable.
/// </summary>
/// <returns>MultipartFormDataParser</returns>
public MultipartFormDataParser BodyFile()BodyForm()
csharp
/// <summary>
/// Parses application/x-www-form-urlencoded contentType given the request body string.
/// </summary>
/// <param name="requestBody">The string request body.</param>
/// <returns>key/value data</returns>
public Dictionary<string, object> BodyForm(string requestBody)