Compressed files are not server when StaticFileOptions has RequestPath
Closed this issue · 2 comments
ilyapalkin commented
Ratioanle
If StaticFileOptions
has RequestPath
path specified and static files are queried as {RequestPath}/path-to-a-static-file
then cached versions are not served.
It says that originalFile
doesn't exist
Test
[TestMethod]
public async Task Should_serve_the_compressed_file_if_a_compressed_version_exists_and_the_browser_supports_it()
{
// Arrange
var builder = new WebHostBuilder()
.Configure(app =>
{
app.UseCompressedStaticFiles(new StaticFileOptions
{
RequestPath = "/assets"
});
app.Use(next =>
{
return async context =>
{
// this test should never call the next middleware
// set status code to 999 to detect a test failure
context.Response.StatusCode = 999;
};
});
}).UseWebRoot(Path.Combine(Environment.CurrentDirectory, "wwwroot"));
var server = new TestServer(builder);
// Act
var client = server.CreateClient();
client.DefaultRequestHeaders.Add("Accept-Encoding", "br, gzip");
var response = await client.GetAsync("/assets/i_also_exist_compressed.html");
var content = await response.Content.ReadAsStringAsync();
// Assert
response.StatusCode.Should().Be(200);
content.Should().Be("br");
response.Content.Headers.TryGetValues("Content-Type", out IEnumerable<string> contentTypeValues);
contentTypeValues.Single().Should().Be("text/html");
}
msschl commented
This would be nice to get fixed.
AnderssonPeter commented
@msschl @ilyapalkin sorry for the huge delay but 2.1.0 is on its way and includes a fix for this