mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
fixed gzip for static resource.
This commit is contained in:
@@ -9,14 +9,19 @@ namespace NzbDrone.Api.Extensions
|
||||
{
|
||||
public static void Handle(NancyContext context)
|
||||
{
|
||||
if (!context.Response.ContentType.Contains("image") && context.Request.Headers.AcceptEncoding.Any(x => x.Contains("gzip")))
|
||||
context.Response.CompressResponse(context.Request);
|
||||
}
|
||||
|
||||
public static Response CompressResponse(this Response response, Request request)
|
||||
{
|
||||
if (!response.ContentType.Contains("image") && request.Headers.AcceptEncoding.Any(x => x.Contains("gzip")))
|
||||
{
|
||||
var data = new MemoryStream();
|
||||
context.Response.Contents.Invoke(data);
|
||||
response.Contents.Invoke(data);
|
||||
data.Position = 0;
|
||||
if (data.Length < 1024)
|
||||
{
|
||||
context.Response.Contents = stream =>
|
||||
response.Contents = stream =>
|
||||
{
|
||||
data.CopyTo(stream);
|
||||
stream.Flush();
|
||||
@@ -24,8 +29,8 @@ namespace NzbDrone.Api.Extensions
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Response.Headers["Content-Encoding"] = "gzip";
|
||||
context.Response.Contents = s =>
|
||||
response.Headers["Content-Encoding"] = "gzip";
|
||||
response.Contents = s =>
|
||||
{
|
||||
var gzip = new GZipStream(s, CompressionMode.Compress, true);
|
||||
data.CopyTo(gzip);
|
||||
@@ -33,6 +38,8 @@ namespace NzbDrone.Api.Extensions
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
@@ -48,7 +48,12 @@ namespace NzbDrone.Api.Series
|
||||
return new NotFoundResponse();
|
||||
}
|
||||
|
||||
return series.AsResponse();
|
||||
|
||||
var resource = ToResource(()=>_seriesService.FindBySlug(slug));
|
||||
|
||||
MapCoversToLocal(resource);
|
||||
|
||||
return resource.AsResponse();
|
||||
}
|
||||
|
||||
private List<SeriesResource> AllSeries()
|
||||
|
Reference in New Issue
Block a user