/// <summary> /// Creates a new instance /// </summary> /// <param name="port">Listen port</param> public EmbeddedHttpServer(uint port) { if (!HttpListener.IsSupported) throw new NotSupportedException("Needs Windows XP SP2, Server 2003 or later."); _listener = new HttpListener(); _handlers = new List<ReqestHandler>(); _listener.Prefixes.Add(string.Format("http://*:{0}/", port)); _log = new ServerLog(); _cache = new Dictionary<string, byte[]>(); AppPackages = new List<string>(); CacheLimit = 10 * 1024 * 1024; //initial cache limit is 10Mb CustomMimeData = new Dictionary<string, string>(); CustomMimeData.Add(".svg", "image/svg+xml"); CustomMimeData.Add(".ttf", "application/x-font-truetype"); CustomMimeData.Add(".eot", "application / vnd.ms - fontobject"); CustomMimeData.Add(".woff", "application/font-woff"); CustomMimeData.Add(".otf", "application/x-font-opentype"); }
/// <summary> /// Creates a new instance /// </summary> /// <param name="port">Listen port</param> public EmbeddedHttpServer(uint port) { if (!HttpListener.IsSupported) { throw new NotSupportedException("Needs Windows XP SP2, Server 2003 or later."); } _listener = new HttpListener(); _handlers = new List <ReqestHandler>(); _listener.Prefixes.Add(string.Format("http://*:{0}/", port)); _log = new ServerLog(); _cache = new Dictionary <string, byte[]>(); AppPackages = new List <string>(); CacheLimit = 10 * 1024 * 1024; //initial cache limit is 10Mb CustomMimeData = new Dictionary <string, string>(); CustomMimeData.Add(".svg", "image/svg+xml"); CustomMimeData.Add(".ttf", "application/x-font-truetype"); CustomMimeData.Add(".eot", "application / vnd.ms - fontobject"); CustomMimeData.Add(".woff", "application/font-woff"); CustomMimeData.Add(".otf", "application/x-font-opentype"); }
public void Dispose() { if (_listener != null) { _listener.Close(); } if (_log != null) { _log.Dispose(); _log = null; } GC.SuppressFinalize(this); }