C# Класс HTTP.HttpProcessor

Implements a Handler for each HTTP Client Request
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
ns NetworkStream

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
ForwardToIndexHTML ( String Message ) : String
ForwardToLastPage ( String Message ) : String
ForwardToPage ( String Message, String URL ) : String

Описание методов

HttpProcessor() публичный Метод

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
Результат System

getFileExtension() публичный Метод

extracts the file extension from a filename
public getFileExtension ( string filename ) : string
filename string the complete filename or path+filename
Результат string

parseRequest() публичный Метод

parses the Request and determines if it's actually a valid one or not
public parseRequest ( ) : bool
Результат bool

process() публичный Метод

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
Результат void

readHeaders() публичный Метод

Reads the headers of the request and determines if they are valid or not
public readHeaders ( ) : bool
Результат bool

writeError() публичный Метод

public writeError ( int status, string message ) : void
status int
message string
Результат void

writeFailure() публичный Метод

public writeFailure ( ) : void
Результат void

writeForbidden() публичный Метод

public writeForbidden ( ) : void
Результат void

writeNotAuthorized() публичный Метод

public writeNotAuthorized ( String realm ) : void
realm String
Результат void

writeResult() публичный Метод

public writeResult ( int status, string message, long length ) : void
status int
message string
length long
Результат void

writeResult() публичный Метод

public writeResult ( int status, string message, long length, string mimetype ) : void
status int
message string
length long
mimetype string
Результат void

writeSuccess() публичный Метод

public writeSuccess ( long length ) : void
length long
Результат void

writeSuccess() публичный Метод

public writeSuccess ( long length, string mimetype ) : void
length long
mimetype string
Результат void

writeURL() публичный Метод

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
Результат void

Описание свойств

ns публичное свойство

public NetworkStream ns
Результат NetworkStream