C# Class HTTP.HttpProcessor

Implements a Handler for each HTTP Client Request
ファイルを表示 Open project: bietiekay/hacs Class Usage Examples

Public Properties

Property Type Description
ns NetworkStream

Public Methods

Method Description
HttpProcessor ( Socket s, String HTTP_DocumentRoot, sones.storage.TinyOnDiskStorage Storage, sones.storage.TinyOnDiskStorage LatitudeStorage, hacs.xs1.configuration.XS1Configuration _XS1_Configuration, hacs.ConsoleOutputLogger Logger, MAXMonitoringThread ELVMAXMonitoring, bool AuthEnabled, String Uname, String Pword, String StartAddrFilter ) : System

Each HTTP processor object handles one client. If Keep-Alive is enabled then this object will be reused for subsequent requests until the client breaks keep-alive. This usually happens when it times out. Because this could easily lead to a DoS attack, we keep track of the number of open processors and only allow 100 to be persistent active at any one time. Additionally, we do not allow more than 500 outstanding requests.

getFileExtension ( string filename ) : string

extracts the file extension from a filename

parseRequest ( ) : bool

parses the Request and determines if it's actually a valid one or not

process ( ) : void

This is the main method of each thread of HTTP processing. We pass this method to the thread constructor when starting a new connection.

readHeaders ( ) : bool

Reads the headers of the request and determines if they are valid or not

writeError ( int status, string message ) : void
writeFailure ( ) : void
writeForbidden ( ) : void
writeNotAuthorized ( String realm ) : void
writeResult ( int status, string message, long length ) : void
writeResult ( int status, string message, long length, string mimetype ) : void
writeSuccess ( long length ) : void
writeSuccess ( long length, string mimetype ) : void
writeURL ( ) : void

We need to make sure that the url that we are trying to treat as a file lies below the document root of the http server so that people can't grab random files off your computer while this is running.

Private Methods

Method Description
ForwardToIndexHTML ( String Message ) : String
ForwardToLastPage ( String Message ) : String
ForwardToPage ( String Message, String URL ) : String

Method Details

HttpProcessor() public method

Each HTTP processor object handles one client. If Keep-Alive is enabled then this object will be reused for subsequent requests until the client breaks keep-alive. This usually happens when it times out. Because this could easily lead to a DoS attack, we keep track of the number of open processors and only allow 100 to be persistent active at any one time. Additionally, we do not allow more than 500 outstanding requests.
public HttpProcessor ( Socket s, String HTTP_DocumentRoot, sones.storage.TinyOnDiskStorage Storage, sones.storage.TinyOnDiskStorage LatitudeStorage, hacs.xs1.configuration.XS1Configuration _XS1_Configuration, hacs.ConsoleOutputLogger Logger, MAXMonitoringThread ELVMAXMonitoring, bool AuthEnabled, String Uname, String Pword, String StartAddrFilter ) : System
s Socket the Socket to work with
HTTP_DocumentRoot String
Storage sones.storage.TinyOnDiskStorage
LatitudeStorage sones.storage.TinyOnDiskStorage
_XS1_Configuration hacs.xs1.configuration.XS1Configuration
Logger hacs.ConsoleOutputLogger
ELVMAXMonitoring hacs.MAXMonitoringThread
AuthEnabled bool
Uname String
Pword String
StartAddrFilter String
return System

getFileExtension() public method

extracts the file extension from a filename
public getFileExtension ( string filename ) : string
filename string the complete filename or path+filename
return string

parseRequest() public method

parses the Request and determines if it's actually a valid one or not
public parseRequest ( ) : bool
return bool

process() public method

This is the main method of each thread of HTTP processing. We pass this method to the thread constructor when starting a new connection.
public process ( ) : void
return void

readHeaders() public method

Reads the headers of the request and determines if they are valid or not
public readHeaders ( ) : bool
return bool

writeError() public method

public writeError ( int status, string message ) : void
status int
message string
return void

writeFailure() public method

public writeFailure ( ) : void
return void

writeForbidden() public method

public writeForbidden ( ) : void
return void

writeNotAuthorized() public method

public writeNotAuthorized ( String realm ) : void
realm String
return void

writeResult() public method

public writeResult ( int status, string message, long length ) : void
status int
message string
length long
return void

writeResult() public method

public writeResult ( int status, string message, long length, string mimetype ) : void
status int
message string
length long
mimetype string
return void

writeSuccess() public method

public writeSuccess ( long length ) : void
length long
return void

writeSuccess() public method

public writeSuccess ( long length, string mimetype ) : void
length long
mimetype string
return void

writeURL() public method

We need to make sure that the url that we are trying to treat as a file lies below the document root of the http server so that people can't grab random files off your computer while this is running.
public writeURL ( ) : void
return void

Property Details

ns public_oe property

public NetworkStream ns
return NetworkStream