/// <summary> /// Initializes a new instance of the <see cref="FileHandler"/> class. /// </summary> /// <param name="server">HTTP server to attach to</param> /// <param name="baseUri">Uri to serve, for instance "/files/"</param> /// <param name="basePath">Path on hard drive where we should start looking for files</param> /// <param name="useLastModifiedHeader">If true a Last-Modifed header will be sent upon requests urging webbrowser to cache files</param> public FileHandler(HttpListener server, string baseUri, string basePath, bool useLastModifiedHeader) { Check.Require(server, "server"); Check.Require(baseUri, "baseUri"); Check.Require(basePath, "basePath"); _server = server; _useLastModifiedHeader = useLastModifiedHeader; _baseUri = baseUri; _basePath = basePath; if (!_basePath.EndsWith(PathSeparator)) _basePath += PathSeparator; ForbiddenChars = DefaultForbiddenChars; AddDefaultMimeTypes(); server.AddHandler("GET", null, "^" + baseUri, true, RequestHandler); }