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
dispatcherHttpMessageHandlerThe 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
configurationHttpConfigurationThe 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
configurationHttpConfigurationThe HttpConfiguration used to configure this instance.
dispatcherHttpMessageHandlerThe 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
disposingbooltrue 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
requestHttpRequestMessageThe request to dispatch.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task<HttpResponseMessage>
A task representing the asynchronous operation.