MTSC  1.0.5
Build TCP servers out of modules with handlers for communication, exception and logging.
MTSC.Common.Http.HttpMessage Class Reference

Public Types

enum  StatusCodes {
  Continue = 100, SwitchingProtocols = 101, OK = 200, Created = 201,
  Accepted = 202, NonAuthoritativeInformation = 203, NoContent = 204, ResetContent = 205,
  PartialContent = 206, MultipleChoices = 300, MovedPermanently = 301, Found = 302,
  SeeOther = 303, NotModified = 304, UseProxy = 305, TemporaryRedirect = 307,
  BadRequest = 400, Unauthorized = 401, PaymentRequired = 402, Forbidden = 403,
  NotFound = 404, MethodNotAllowed = 405, NotAcceptable = 406, ProxyAuthenticationRequired = 407,
  RequestTimeout = 408, Conflict = 409, Gone = 410, LengthRequired = 411,
  PreconditionFailed = 412, RequestEntityTooLarge = 413, RequestURITooLarge = 414, UnsupportedMediaType = 415,
  RequestRangeNotSatisfiable = 416, ExpectationFailed = 417, InternalServerError = 500, NotImplemented = 501,
  BadGateway = 502, ServiceUnavailable = 503, GatewayTimeout = 504, HTTPVersionNotSupported = 505
}
 
enum  MethodEnum {
  Options = 0, Get = 1, Head = 2, Post = 3,
  Put = 4, Delete = 5, Trace = 6, Connect = 7,
  ExtensionMethod = 8
}
 
enum  GeneralHeadersEnum {
  CacheControl = 0, Connection = 1, Date = 2, Pragma = 3,
  Trailer = 4, TransferEncoding = 5, Upgrade = 6, Via = 7,
  Warning = 8
}
 
enum  RequestHeadersEnum {
  Accept = 0, AcceptCharset = 1, AcceptEncoding = 2, AcceptLanguage = 3,
  Authorization = 4, Expect = 5, From = 6, Host = 7,
  IfMatch = 8, IfModifiedSince = 9, IfNoneMatch = 10, IfRange = 11,
  IfUnmodifiedSince = 12, MaxForwards = 13, ProxyAuthorization = 14, Range = 15,
  Referer = 16, TE = 17, UserAgent = 18
}
 
enum  ResponseHeadersEnum {
  AcceptRanges = 0, Age = 1, ETag = 2, Location = 3,
  ProxyAuthentication = 4, RetryAfter = 5, Server = 6, Vary = 7,
  WWWAuthenticate = 8
}
 
enum  EntityHeadersEnum {
  Allow = 0, ContentEncoding = 1, ContentLanguage = 2, ContentLength = 3,
  ContentLocation = 4, ContentMD5 = 5, ContentRange = 6, ContentType = 7,
  Expired = 8, LastModified = 9
}
 

Public Member Functions

void AddGeneralHeader (GeneralHeadersEnum header, string value)
 Add a general header to the message. More...
 
void AddRequestHeader (RequestHeadersEnum requestHeader, string value)
 Add a request header to the message. More...
 
void AddResponseHeader (ResponseHeadersEnum responseHeader, string value)
 Add a response header to the message. More...
 
void AddEntityHeaders (EntityHeadersEnum entityHeader, string value)
 Add an entity header to the message. More...
 
byte [] BuildRequest ()
 Build the request bytes based on the message contents. More...
 
void ParseRequest (byte[] requestBytes)
 Parse the received bytes and populate the message contents. More...
 
byte [] BuildResponse (bool includeContentLengthHeader)
 Build the response bytes based on the message contents. More...
 
void ParseResponse (byte[] responseBytes)
 Parse the received bytes and populate the message contents. More...
 
bool ContainsHeader (ResponseHeadersEnum header)
 Check if the message contains a header. More...
 
bool ContainsHeader (RequestHeadersEnum header)
 Check if the message contains a header. More...
 
bool ContainsHeader (GeneralHeadersEnum header)
 Check if the message contains a header. More...
 
bool ContainsHeader (EntityHeadersEnum header)
 Check if the message contains a header. More...
 
bool ContainsHeader (string header)
 Check if the message contains a header. More...
 
Dictionary< string, string > GetPostForm ()
 Parse the body into a posted from respecting the reference manual. More...
 

Properties

MethodEnum Method [get, set]
 
string RequestURI [get, set]
 
string RequestQuery [get, set]
 
byte [] Body [get, set]
 
StatusCodes StatusCode [get, set]
 
string this[string headerKey] [get, set]
 Headers dictionary. More...
 
string this[GeneralHeadersEnum headerKey] [get, set]
 Headers dictionary. More...
 
string this[ResponseHeadersEnum headerKey] [get, set]
 Headers dictionary. More...
 
string this[RequestHeadersEnum headerKey] [get, set]
 Headers dictionary. More...
 
string this[EntityHeadersEnum headerKey] [get, set]
 Headers dictionary. More...
 
List< CookieCookies [get]
 List of cookies. More...
 

Detailed Description

Definition at line 8 of file HttpMessage.cs.

Member Function Documentation

◆ AddEntityHeaders()

void MTSC.Common.Http.HttpMessage.AddEntityHeaders ( EntityHeadersEnum  entityHeader,
string  value 
)

Add an entity header to the message.

Parameters
entityHeaderHeader key.
valueHeader value.

Definition at line 224 of file HttpMessage.cs.

◆ AddGeneralHeader()

void MTSC.Common.Http.HttpMessage.AddGeneralHeader ( GeneralHeadersEnum  header,
string  value 
)

Add a general header to the message.

Parameters
headerHeader key.
valueHeader value.

Definition at line 197 of file HttpMessage.cs.

◆ AddRequestHeader()

void MTSC.Common.Http.HttpMessage.AddRequestHeader ( RequestHeadersEnum  requestHeader,
string  value 
)

Add a request header to the message.

Parameters
requestHeaderHeader key.
valueHeader value.

Definition at line 206 of file HttpMessage.cs.

◆ AddResponseHeader()

void MTSC.Common.Http.HttpMessage.AddResponseHeader ( ResponseHeadersEnum  responseHeader,
string  value 
)

Add a response header to the message.

Parameters
responseHeaderHeader key.
valueHeader value.

Definition at line 215 of file HttpMessage.cs.

◆ BuildRequest()

byte [] MTSC.Common.Http.HttpMessage.BuildRequest ( )

Build the request bytes based on the message contents.

Returns
Array of bytes.

Definition at line 232 of file HttpMessage.cs.

◆ BuildResponse()

byte [] MTSC.Common.Http.HttpMessage.BuildResponse ( bool  includeContentLengthHeader)

Build the response bytes based on the message contents.

Parameters
includeContentLengthHeaderIf set to true, add an extra Content-Length header specifying the length of the body.
Returns
Array of bytes.

Definition at line 372 of file HttpMessage.cs.

◆ ContainsHeader() [1/5]

bool MTSC.Common.Http.HttpMessage.ContainsHeader ( ResponseHeadersEnum  header)

Check if the message contains a header.

Parameters
headerKey of the header.
Returns
True if the message contains a header with the provided key.

Definition at line 500 of file HttpMessage.cs.

◆ ContainsHeader() [2/5]

bool MTSC.Common.Http.HttpMessage.ContainsHeader ( RequestHeadersEnum  header)

Check if the message contains a header.

Parameters
headerKey of the header.
Returns
True if the message contains a header with the provided key.

Definition at line 509 of file HttpMessage.cs.

◆ ContainsHeader() [3/5]

bool MTSC.Common.Http.HttpMessage.ContainsHeader ( GeneralHeadersEnum  header)

Check if the message contains a header.

Parameters
headerKey of the header.
Returns
True if the message contains a header with the provided key.

Definition at line 518 of file HttpMessage.cs.

◆ ContainsHeader() [4/5]

bool MTSC.Common.Http.HttpMessage.ContainsHeader ( EntityHeadersEnum  header)

Check if the message contains a header.

Parameters
headerKey of the header.
Returns
True if the message contains a header with the provided key.

Definition at line 527 of file HttpMessage.cs.

◆ ContainsHeader() [5/5]

bool MTSC.Common.Http.HttpMessage.ContainsHeader ( string  header)

Check if the message contains a header.

Parameters
headerKey of the header.
Returns
True if the message contains a header with the provided key.

Definition at line 536 of file HttpMessage.cs.

◆ GetPostForm()

Dictionary<string, string> MTSC.Common.Http.HttpMessage.GetPostForm ( )

Parse the body into a posted from respecting the reference manual.

Returns
Dictionary with posted from.

Definition at line 544 of file HttpMessage.cs.

◆ ParseRequest()

void MTSC.Common.Http.HttpMessage.ParseRequest ( byte []  requestBytes)

Parse the received bytes and populate the message contents.

Parameters
requestBytesMessage bytes to be parsed.

Definition at line 267 of file HttpMessage.cs.

◆ ParseResponse()

void MTSC.Common.Http.HttpMessage.ParseResponse ( byte []  responseBytes)

Parse the received bytes and populate the message contents.

Parameters
responseBytesArray of bytes to be parsed.

Definition at line 406 of file HttpMessage.cs.

Property Documentation

◆ Cookies

List<Cookie> MTSC.Common.Http.HttpMessage.Cookies
get

List of cookies.

Definition at line 191 of file HttpMessage.cs.

◆ this[EntityHeadersEnum headerKey]

string MTSC.Common.Http.HttpMessage.this[EntityHeadersEnum headerKey]
getset

Headers dictionary.

Parameters
headerKeyKey of the header.
Returns
Value of the header.

Definition at line 187 of file HttpMessage.cs.

◆ this[GeneralHeadersEnum headerKey]

string MTSC.Common.Http.HttpMessage.this[GeneralHeadersEnum headerKey]
getset

Headers dictionary.

Parameters
headerKeyKey of the header.
Returns
Value of the header.

Definition at line 169 of file HttpMessage.cs.

◆ this[RequestHeadersEnum headerKey]

string MTSC.Common.Http.HttpMessage.this[RequestHeadersEnum headerKey]
getset

Headers dictionary.

Parameters
headerKeyKey of the header.
Returns
Value of the header.

Definition at line 181 of file HttpMessage.cs.

◆ this[ResponseHeadersEnum headerKey]

string MTSC.Common.Http.HttpMessage.this[ResponseHeadersEnum headerKey]
getset

Headers dictionary.

Parameters
headerKeyKey of the header.
Returns
Value of the header.

Definition at line 175 of file HttpMessage.cs.

◆ this[string headerKey]

string MTSC.Common.Http.HttpMessage.this[string headerKey]
getset

Headers dictionary.

Parameters
headerKeyKey of the header.
Returns
Value of the header.

Definition at line 163 of file HttpMessage.cs.


The documentation for this class was generated from the following file: