C# Класс HttpServer.Server

Наследование: HttpServer.ServerBase
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
Add ( IBodyDecoder decoder ) : void

Add a decoder.

Adding zero decoders will make the server add the default ones which is MultiPartDecoder and UrlDecoder.

Add ( IHttpListener listener ) : void

Add a HTTP listener.

Add ( IModule module ) : void

Add a file module

Add ( IRouter router ) : void

Add a new router.

Server ( ) : System

Initializes a new instance of the Server class.

Server ( HttpFactory factory ) : System

Initializes a new instance of the Server class.

Start ( int backLog ) : void

Start http server.

Stop ( bool removeModules ) : void

Stops the server

Защищенные методы

Метод Описание
DecodeBody ( IRequest request ) : void
DisplayErrorPage ( IHttpContext context, Exception exception ) : void

An error have occurred and we need to send a result pack to the client

Invoke base class (Server) to send the contents of IHttpContext.Response.

OnAuthentication ( HttpServer.RequestContext context ) : void

Called before anything else.

Looks after a AuthorizationHeader in the request and will use the AuthenticationProvider if found.

OnBeforeModules ( HttpServer.RequestContext context ) : void

All server modules are about to be invoked.

Called when routers have been invoked but no modules yet.

OnBeforeRequest ( HttpServer.RequestContext context ) : void

A request have arrived but not yet been processed yet.

Default implementation adds a Date header and Server header.

ProcessResult ( ProcessingResult result, HttpServer.RequestEventArgs e ) : bool

Process result (check if it should be sent back or not)

RequestAuthentication ( string realm ) : void

Requests authentication from the user.

Used when calculating hashes in Digest authentication.

SendResponse ( IHttpContext context, IRequest request, IResponse response ) : void

Send a response.

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

Метод Описание
HandleRequest ( HttpServer.RequestEventArgs e ) : ProcessingResult
Listener_OnErrorPage ( object sender, HttpServer.ErrorPageEventArgs e ) : void
OnRequest ( object sender, HttpServer.RequestEventArgs e ) : void
ProcessModules ( HttpServer.RequestContext context ) : ProcessingResult

Go through all modules and check if any of them can handle the current request.

ProcessRouters ( HttpServer.RequestContext context ) : ProcessingResult

Processes all routers.

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

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

Add a decoder.
Adding zero decoders will make the server add the default ones which is MultiPartDecoder and UrlDecoder.
public Add ( IBodyDecoder decoder ) : void
decoder IBodyDecoder decoder to add
Результат void

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

Add a HTTP listener.
Listener have been started.
public Add ( IHttpListener listener ) : void
listener IHttpListener
Результат void

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

Add a file module
module is null. Cannot add modules when server have been started.
public Add ( IModule module ) : void
module IModule Module to add
Результат void

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

Add a new router.
Server have been started.
public Add ( IRouter router ) : void
router IRouter Router to add
Результат void

DecodeBody() защищенный Метод

protected DecodeBody ( IRequest request ) : void
request IRequest
Результат void

DisplayErrorPage() защищенный Метод

An error have occurred and we need to send a result pack to the client
Invoke base class (Server) to send the contents of IHttpContext.Response.
protected DisplayErrorPage ( IHttpContext context, Exception exception ) : void
context IHttpContext The context.
exception System.Exception The exception.
Результат void

OnAuthentication() защищенный Метод

Called before anything else.
Looks after a AuthorizationHeader in the request and will use the AuthenticationProvider if found.
protected OnAuthentication ( HttpServer.RequestContext context ) : void
context HttpServer.RequestContext The context.
Результат void

OnBeforeModules() защищенный Метод

All server modules are about to be invoked.
Called when routers have been invoked but no modules yet.
protected OnBeforeModules ( HttpServer.RequestContext context ) : void
context HttpServer.RequestContext The context.
Результат void

OnBeforeRequest() защищенный Метод

A request have arrived but not yet been processed yet.
Default implementation adds a Date header and Server header.
protected OnBeforeRequest ( HttpServer.RequestContext context ) : void
context HttpServer.RequestContext The context.
Результат void

ProcessResult() защищенный Метод

Process result (check if it should be sent back or not)
protected ProcessResult ( ProcessingResult result, HttpServer.RequestEventArgs e ) : bool
result ProcessingResult
e HttpServer.RequestEventArgs
Результат bool

RequestAuthentication() защищенный Метод

Requests authentication from the user.
Used when calculating hashes in Digest authentication.
protected RequestAuthentication ( string realm ) : void
realm string Host/domain name that the server hosts.
Результат void

SendResponse() защищенный Метод

Send a response.
protected SendResponse ( IHttpContext context, IRequest request, IResponse response ) : void
context IHttpContext
request IRequest
response IResponse
Результат void

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

Initializes a new instance of the Server class.
public Server ( ) : System
Результат System

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

Initializes a new instance of the Server class.
public Server ( HttpFactory factory ) : System
factory HttpFactory Factory used to create objects used in this library.
Результат System

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

Start http server.
public Start ( int backLog ) : void
backLog int Number of pending connections.
Результат void

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

Stops the server
public Stop ( bool removeModules ) : void
removeModules bool true if all modules should be removed.
Результат void