public void TryGetResponseContentReturnsCorrectContentTypeForNonPhysicalFile() { // Arrange const string cssFilePath = "folder/file.css"; const string cssFileContent = "this is css"; var inMemoryFileProvider = new InMemoryFileProvider( new Dictionary <string, string> { { cssFilePath, cssFileContent }, }); var appBase = "fake://0.0.0.0/"; var scp = new StaticContentProvider(inMemoryFileProvider, new Uri(appBase), "fakehost.html"); // Act Assert.True(scp.TryGetResponseContent( requestUri: appBase + cssFilePath, allowFallbackOnHostPage: false, out var statusCode, out var statusMessage, out var content, out var headers)); // Assert var contentString = new StreamReader(content).ReadToEnd(); Assert.Equal(200, statusCode); Assert.Equal("OK", statusMessage); Assert.Equal("this is css", contentString); Assert.True(headers.TryGetValue("Content-Type", out var contentTypeValue)); Assert.Equal("text/css", contentTypeValue); }
private StaticContentProvider BuildStaticContentProvider() { var rootPathProvider = new RootPathProvider(); var staticContnetConventions = new StaticContentsConventions(new List <Func <Context, string, Response> > { StaticContentConventionBuilder.AddDirectory("Content") }); var staticContentProvider = new StaticContentProvider(rootPathProvider, staticContnetConventions); FileResponse.SafePaths.Add(rootPathProvider.GetRootPath()); return(staticContentProvider); }
public Engine(StaticContentProvider staticContentProvider, RequestDispatcher requestDispatcher) { if (staticContentProvider == null) { throw new ArgumentNullException("staticContentProvider"); } if (requestDispatcher == null) { throw new ArgumentNullException("requestDispatcher"); } _staticContentProvider = staticContentProvider; _requestDispatcher = requestDispatcher; }