C# Class HTTP.HttpProcessor

Implements a Handler for each HTTP Client Request
Afficher le fichier Open project: bietiekay/hacs Class Usage Examples

Méthodes publiques

Свойство Type Description
ns NetworkStream

Méthodes publiques

Méthode 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

Méthode Description
ForwardToIndexHTML ( String Message ) : String
ForwardToLastPage ( String Message ) : String
ForwardToPage ( String Message, String URL ) : String

Method Details

HttpProcessor() public méthode

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
Résultat System

getFileExtension() public méthode

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

parseRequest() public méthode

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

process() public méthode

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
Résultat void

readHeaders() public méthode

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

writeError() public méthode

public writeError ( int status, string message ) : void
status int
message string
Résultat void

writeFailure() public méthode

public writeFailure ( ) : void
Résultat void

writeForbidden() public méthode

public writeForbidden ( ) : void
Résultat void

writeNotAuthorized() public méthode

public writeNotAuthorized ( String realm ) : void
realm String
Résultat void

writeResult() public méthode

public writeResult ( int status, string message, long length ) : void
status int
message string
length long
Résultat void

writeResult() public méthode

public writeResult ( int status, string message, long length, string mimetype ) : void
status int
message string
length long
mimetype string
Résultat void

writeSuccess() public méthode

public writeSuccess ( long length ) : void
length long
Résultat void

writeSuccess() public méthode

public writeSuccess ( long length, string mimetype ) : void
length long
mimetype string
Résultat void

writeURL() public méthode

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
Résultat void

Property Details

ns public_oe property

public NetworkStream ns
Résultat NetworkStream