public void DashedExtensionsShouldBeMatched() { var provider = new FileExtensionContentTypeProvider(); string contentType; provider.TryGetContentType("known.dvr-ms", out contentType).ShouldBe(true); contentType.ShouldBe("video/x-ms-dvr"); }
public void KnownExtensionsReturnTrye() { var provider = new FileExtensionContentTypeProvider(); string contentType; provider.TryGetContentType("known.txt", out contentType).ShouldBe(true); contentType.ShouldBe("text/plain"); }
public DocfxSeedSiteFixture() { JObject token = JObject.Parse(File.ReadAllText(ConfigFile)); var folder = (string)token.SelectToken("site"); var port = (int)token.SelectToken("port"); Driver = new FirefoxDriver(); Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); Driver.Manage().Window.Maximize(); try { var contentTypeProvider = new FileExtensionContentTypeProvider(); // register yaml MIME as OWIN doesn't host it by default. // http://stackoverflow.com/questions/332129/yaml-mime-type contentTypeProvider.Mappings[".yml"] = "application/x-yaml"; var fileServerOptions = new FileServerOptions { EnableDirectoryBrowsing = true, FileSystem = new PhysicalFileSystem(folder), StaticFileOptions = { ContentTypeProvider = contentTypeProvider } }; Url = $"{RootUrl}:{port}"; WebApp.Start(Url, builder => builder.UseFileServer(fileServerOptions)); } catch (System.Reflection.TargetInvocationException) { Console.WriteLine($"Error serving \"{folder}\" on \"{Url}\", check if the port is already being in use."); } }
public void DotsInDirectoryAreIgnored() { var provider = new FileExtensionContentTypeProvider(); string contentType; provider.TryGetContentType(@"/first.css/example.txt", out contentType).ShouldBe(true); contentType.ShouldBe("text/plain"); provider.TryGetContentType(@"\second.css\example.txt", out contentType).ShouldBe(true); contentType.ShouldBe("text/plain"); }
public void BothSlashFormatsAreUnderstood() { var provider = new FileExtensionContentTypeProvider(); string contentType; provider.TryGetContentType(@"/first/example.txt", out contentType).ShouldBe(true); contentType.ShouldBe("text/plain"); provider.TryGetContentType(@"\second\example.txt", out contentType).ShouldBe(true); contentType.ShouldBe("text/plain"); }
public static IAppBuilder UseStaticFilesServer(this IAppBuilder app, string path) { var provider = new FileExtensionContentTypeProvider(); provider.Mappings.Add(".odt", "application/vnd.oasis.opendocument.text"); return app.UseStaticFiles(new StaticFileOptions() { FileSystem = new PhysicalFileSystem(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, Globals.Constants.RootFolder, Globals.Constants.Uploads)), //RequestPath = new PathString(path), ContentTypeProvider = provider }); }
private void ConfigureStaticFileServer(IAppBuilder builder) { var contentTypeProvider = new FileExtensionContentTypeProvider(); contentTypeProvider.Mappings.Add(".json", "application/json"); var options = new FileServerOptions { EnableDirectoryBrowsing = true, EnableDefaultFiles = true, FileSystem = new PhysicalFileSystem(_staticFilesRoot) }; options.DefaultFilesOptions.DefaultFileNames.Add("about.html"); options.StaticFileOptions.ContentTypeProvider = contentTypeProvider; builder.UseFileServer(options); }
public void DoubleDottedExtensionsAreNotSupported() { var provider = new FileExtensionContentTypeProvider(); string contentType; provider.TryGetContentType("known.exe.config", out contentType).ShouldBe(false); }
public void UnknownExtensionsReturnFalse() { var provider = new FileExtensionContentTypeProvider(); string contentType; provider.TryGetContentType("unknown.ext", out contentType).ShouldBe(false); }