Class HttpServer
Defines an implementation of an HttpMessageHandler which dispatches an incoming HttpRequestMessage and creates an HttpResponseMessage as a result.
public class HttpServer : DelegatingHandler, IDisposable
- Inheritance
-
HttpServer
- Implements
- Inherited Members
Constructors
HttpServer()
Initializes a new instance of the HttpServer class, using the default configuration and dispatcher.
public HttpServer()
HttpServer(HttpMessageHandler)
Initializes a new instance of the HttpServer class with a specified dispatcher.
public HttpServer(HttpMessageHandler dispatcher)
Parameters
dispatcher
HttpMessageHandlerThe HTTP dispatcher that will handle incoming requests.
HttpServer(HttpConfiguration)
Initializes a new instance of the HttpServer class with a specified configuration.
public HttpServer(HttpConfiguration configuration)
Parameters
configuration
HttpConfigurationThe HttpConfiguration used to configure this instance.
HttpServer(HttpConfiguration, HttpMessageHandler)
Initializes a new instance of the HttpServer class with a specified configuration and dispatcher.
public HttpServer(HttpConfiguration configuration, HttpMessageHandler dispatcher)
Parameters
configuration
HttpConfigurationThe HttpConfiguration used to configure this instance.
dispatcher
HttpMessageHandlerThe HTTP dispatcher that will handle incoming requests.
Properties
Configuration
Gets the HttpConfiguration used to configure this instance.
public HttpConfiguration Configuration { get; }
Property Value
- HttpConfiguration
The HttpConfiguration used to configure this instance.
Dispatcher
Gets the HTTP dispatcher that handles incoming requests.
public HttpMessageHandler Dispatcher { get; }
Property Value
- HttpMessageHandler
The HTTP dispatcher that handles incoming requests.
Methods
Dispose(bool)
Releases the unmanaged resources that are used by the object and, optionally, releases the managed resources.
protected override void Dispose(bool disposing)
Parameters
disposing
booltrue to release both managed and unmanaged resources; false to release only unmanaged resources.
Initialize()
Prepares the server for operation.
protected virtual void Initialize()
SendAsync(HttpRequestMessage, CancellationToken)
Dispatches an incoming HttpRequestMessage.
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
Parameters
request
HttpRequestMessageThe request to dispatch.
cancellationToken
CancellationTokenThe token to monitor for cancellation requests.
Returns
- Task<HttpResponseMessage>
A task representing the asynchronous operation.