C# Класс HttpServer.WebServer

HTTP server with regular expression path matching, client and server SSL certificates, and a simplified request callback
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
AddHandler ( HttpRequestHandler handler ) : void

Add a request handler

AddHandler ( string method, string contentType, string path, HttpRequestCallback callback ) : void

Add a request handler

RemoveHandler ( HttpRequestHandler handler ) : void

Remove a request handler

Set404Handler ( HttpRequestCallback callback ) : void

Set a callback to override the default 404 (Not Found) response

Start ( ) : void

Start the server

Stop ( ) : void

Stop the server

WebServer ( IPAddress address, int port ) : System

Initialize the server in HTTP mode

WebServer ( IPAddress address, int port, X509Certificate certificate, X509Certificate rootCA, bool requireClientCerts ) : System

Initialize the server in HTTPS (TLS 1.0) mode

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

Метод Описание
FireRequestCallback ( IHttpClientContext client, IHttpRequest request, IHttpResponse response, HttpRequestCallback callback ) : void
RequestHandler ( IHttpClientContext client, IHttpRequest request ) : void

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

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

Add a request handler
public AddHandler ( HttpRequestHandler handler ) : void
handler HttpRequestHandler Request handler to add
Результат void

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

Add a request handler
public AddHandler ( string method, string contentType, string path, HttpRequestCallback callback ) : void
method string HTTP verb to match, or null to skip verb matching
contentType string Content-Type header to match, or null to skip Content-Type matching
path string Request URI path regular expression to match, or null to skip URI path matching
callback HttpRequestCallback Callback to fire when an incoming request matches the given pattern
Результат void

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

Remove a request handler
public RemoveHandler ( HttpRequestHandler handler ) : void
handler HttpRequestHandler Request handler to remove
Результат void

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

Set a callback to override the default 404 (Not Found) response
public Set404Handler ( HttpRequestCallback callback ) : void
callback HttpRequestCallback Callback that will be fired when an unhandled /// request is received, or null to reset to the default handler
Результат void

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

Start the server
public Start ( ) : void
Результат void

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

Stop the server
public Stop ( ) : void
Результат void

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

Initialize the server in HTTP mode
public WebServer ( IPAddress address, int port ) : System
address System.Net.IPAddress IP address to bind to
port int Port number to bind to
Результат System

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

Initialize the server in HTTPS (TLS 1.0) mode
public WebServer ( IPAddress address, int port, X509Certificate certificate, X509Certificate rootCA, bool requireClientCerts ) : System
address System.Net.IPAddress IP address to bind to
port int Port number to bind to
certificate System.Security.Cryptography.X509Certificates.X509Certificate X.509 server certificate for SSL
rootCA System.Security.Cryptography.X509Certificates.X509Certificate X.509 certificate for the root certificate authority /// that signed the server certificate and/or any client certificates
requireClientCerts bool True if client SSL certificates are /// required, otherwise false
Результат System