Class
HttpServer
Provides an lightweight HTTP server powered by Sisk.
public sealed class HttpServer : IDisposableInheritance #
Implements #
Inherited Members #
object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Constructors #
| Name | Description |
|---|---|
| HttpServer() | Creates an new HttpServer instance with no predefined configuration. |
| HttpServer(HttpServerConfiguration) | Creates a new default configuration HttpServer instance with the given Route and server configuration. |
Properties #
| Name | Description |
|---|---|
| EventSources | Gets an HttpEventSourceCollection with active event source connections in this HTTP server. |
| IsDynamicCodeSupported | Gets an Boolean indicating if the current environment supports dynamic code or it’s running in an AOT assembly. |
| IsListening | Gets an boolean indicating if this HTTP server is running and listening. |
| IsSupported | Gets an Boolean indicating if Sisk can be used with the current environment. |
| ListeningPrefixes | Gets an string array containing all URL prefixes which this HTTP server is listening to. |
| PoweredBy | Gets the X-Powered-By Sisk header value. |
| ServerConfiguration | Gets or sets the Server Configuration object. |
| SiskVersion | Gets the current Sisk version. |
| WebSockets | Gets an HttpWebSocketConnectionCollection with active Web Sockets connections in this HTTP server. |
Methods #
| Name | Description |
|---|---|
| CreateBuilder(Action<HttpServerHostContextBuilder>) | Builds an HttpServerHostContext context invoking the handler on it. |
| CreateBuilder(ushort) | Builds an empty HttpServerHostContext context with predefined listening port. |
| CreateBuilder(string) | Builds an empty HttpServerHostContext context with predefined listening host string. |
| CreateBuilder() | Builds an empty HttpServerHostContext context. |
| CreateListener() | Gets an listening and running HTTP server in an random port. |
| CreateListener(ushort) | Gets an listening and running HTTP server in the specified port. |
| CreateListener(ushort, out HttpServerConfiguration, out ListeningHost, out Router) | Gets an listening and running HTTP server in the specified port. |
| Dispose() | Invalidates this class and releases the resources used by it, and permanently closes the HTTP server. |
| Emit(ushort, out HttpServerConfiguration, out ListeningHost, out Router) | Gets an non-listening HTTP server with configuration, listening host, and router. |
| HandleContext(HttpServerEngineContext) | Handles a single HttpServerEngineContext request. |
| RegisterHandler<T>() | Associate an HttpServerHandler in this HttpServer to handle functions such as requests, routers and contexts. |
| RegisterHandler(HttpServerHandler) | Associate an HttpServerHandler in this HttpServer to handle functions such as requests, routers and contexts. |
| Restart() | Restarts this HTTP server, sending all processing responses and starting them again, reading the listening ports again. |
| Start() | Starts listening to the set port and handling requests on this server. |
| Stop() | Stops the server from listening and stops the request handler. |
| WaitNext(TimeSpan) | Waits for the next HTTP request to be processed, with a specified timeout. |
| WaitNext(CancellationToken) | Waits for the next HTTP request to be processed, with a specified cancellation token. |
| WaitNextAsync(TimeSpan) | Asynchronously waits for the next HTTP request to be processed, with a specified timeout. |
| WaitNextAsync(CancellationToken) | Asynchronously waits for the next HTTP request to be processed, with a specified cancellation token. |