Skip to content

Commit

Permalink
may have found the problem
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanBout committed Nov 28, 2024
1 parent 6e03599 commit fb52d27
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
5 changes: 3 additions & 2 deletions SimpleCDN/CDNLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ public class CDNLoader(IWebHostEnvironment environment, IOptionsMonitor<CDNConfi
IsCompressed = true
};

return new CDNFile(bytes, mime.ToContentTypeString(), info.LastModified, false);
} else
return new CDNFile(bytes, mime.ToContentTypeString(), info.LastModified, true);
}
else
{
using var stream = info.CreateReadStream();
var bytes = new byte[stream.Length];
Expand Down
18 changes: 9 additions & 9 deletions SimpleCDN/Endpoints/CDN.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ public static IEndpointRouteBuilder RegisterCDNEndpoints(this IEndpointRouteBuil

byte[] bytes = file.Content;

//if (file.IsCompressed && acceptsGzip)
//{
// ctx.Response.Headers.ContentEncoding = new(["gzip", .. ctx.Response.Headers.ContentEncoding.AsEnumerable()]);
//} else if (file.IsCompressed) // file is compressed but client doesn't accept gzip
//{
// Logger.LogWarning("Client does not accept gzip encoding.");
// // decompress the file
// bytes = GZipHelpers.Decompress(bytes);
//}
if (file.IsCompressed && acceptsGzip)
{
ctx.Response.Headers.ContentEncoding = new(["gzip", .. ctx.Response.Headers.ContentEncoding.AsEnumerable()]);
} else if (file.IsCompressed) // file is compressed but client doesn't accept gzip
{
Logger.LogWarning("Client does not accept gzip encoding.");
// decompress the file
bytes = GZipHelpers.Decompress(bytes);
}

return Results.File(bytes, file.MediaType, lastModified: file.LastModified);
}
Expand Down

0 comments on commit fb52d27

Please sign in to comment.