Clone wiki

vds-web-server / Home



VDS.Web.Server was designed as a lightweight HTTP server for embedding in other applications. It is a completely self contained library with no dependencies that uses a HttpListener to provide a simple but powerful web server framework.

Core Concepts

The core of the API is the HttpServer class which represents an instance of a server, this class is used to create and configure your server and to manage its run state as desired.

The server consists of a number of components which embody different parts of functionality of the server:

  • The Handlers Collection maintains the mappings from HTTP request paths to Handler instances which are capable of processing requests.
  • The pre-request and pre-response Modules are used to take actions before a request is processed and before the response to the client is finalized.
  • The Loggers are used to log HTTP requests
  • The MIME Types Manager is used to determine how the server returns static content.
  • The Virtual Directory Manager is used to manage virtual directories.
  • The Console is used to log informational and error messages.

Request Processing Pipeline

A HTTP request received by the server goes through the following processing pipeline:

  1. The HttpServer's internal HttpListener receives the HTTP request and hands it off to the request processor
  2. The request processor applies the pre-request modules
    1. Any module may signals that the server should skip any further processing, skip to step ?
    2. Otherwise continue to step 3
  3. The server attempts to map the request to a request handler
    1. If there is a handler proceed to step 4
    2. Otherwise return 404 Not Found and skip to step 5
  4. The request processor applies the pre-response modules
  5. The request processor flushes the response stream and closes the response