C# Class HttpServer.HttpRequestParser

Parses a HTTP request directly from a stream
Exibir arquivo Open project: 3di/3di-viewer-rei-libs Class Usage Examples

Private Properties

Property Type Description
AddToBody int
Clear void

Public Methods

Method Description
HttpRequestParser ( RequestCompletedHandler requestCompleted, ILogWriter logWriter ) : System

Create a new request parser

ParseMessage ( byte buffer, int offset, int size ) : int

Parse a message

Protected Methods

Method Description
OnFirstLine ( string value ) : void

Parse request line

Expects the following format: "Method SP Request-URI SP HTTP-Version CRLF"

OnHeader ( string name, string value ) : void

We've parsed a new header.

Private Methods

Method Description
AddToBody ( byte buffer, int offset, int count ) : int

Add a number of bytes to the body

Clear ( ) : void

Remove all state information for the request.

Method Details

HttpRequestParser() public method

Create a new request parser
public HttpRequestParser ( RequestCompletedHandler requestCompleted, ILogWriter logWriter ) : System
requestCompleted RequestCompletedHandler delegate called when a complete request have been generated
logWriter ILogWriter delegate receiving log entries.
return System

OnFirstLine() protected method

Parse request line
Expects the following format: "Method SP Request-URI SP HTTP-Version CRLF"
If line is incorrect
protected OnFirstLine ( string value ) : void
value string
return void

OnHeader() protected method

We've parsed a new header.
If content length cannot be parsed.
protected OnHeader ( string name, string value ) : void
name string Name in lower case
value string Value, unmodified.
return void

ParseMessage() public method

Parse a message
public ParseMessage ( byte buffer, int offset, int size ) : int
buffer byte
offset int where in buffer that parsing should start
size int number of bytes to parse
return int