Skip to content

Commit a60b9c1

Browse files
committed
fix response compression bug
1 parent fffba4b commit a60b9c1

4 files changed

Lines changed: 4 additions & 11 deletions

File tree

NpgsqlRestClient/AppStaticFileMiddleware.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -226,17 +226,8 @@ public async Task InvokeAsync(HttpContext context)
226226
try
227227
{
228228
byte[] buffer;
229-
if (_parser is null)
229+
if (_parser is null || isInParsePattern is false)
230230
{
231-
context.Response.ContentLength = length;
232-
using var fileStream = new FileStream(fileInfo.PhysicalPath!, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize: 8192, useAsync: true);
233-
await fileStream.CopyToAsync(context.Response.Body, context.RequestAborted);
234-
return;
235-
}
236-
237-
if (isInParsePattern is false)
238-
{
239-
context.Response.ContentLength = length;
240231
using var fileStream = new FileStream(fileInfo.PhysicalPath!, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize: 8192, useAsync: true);
241232
await fileStream.CopyToAsync(context.Response.Body, context.RequestAborted);
242233
return;

NpgsqlRestClient/Builder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,7 @@ public bool ConfigureResponseCompression()
905905
"text/plain",
906906
"text/css",
907907
"application/javascript",
908+
"text/javascript",
908909
"text/html",
909910
"application/xml",
910911
"text/xml",

NpgsqlRestClient/ConfigDefaults.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ private static JsonObject GetResponseCompressionDefaults()
304304
["UseGzipFallback"] = true,
305305
["CompressionLevel"] = "Optimal",
306306
["IncludeMimeTypes"] = CreateStringArray(
307-
"text/plain", "text/css", "application/javascript", "text/html",
307+
"text/plain", "text/css", "application/javascript", "text/javascript", "text/html",
308308
"application/xml", "text/xml", "application/json", "text/json",
309309
"image/svg+xml", "font/woff", "font/woff2", "application/font-woff", "application/font-woff2"
310310
),

NpgsqlRestClient/appsettings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,7 @@
914914
"text/plain",
915915
"text/css",
916916
"application/javascript",
917+
"text/javascript",
917918
"text/html",
918919
"application/xml",
919920
"text/xml",

0 commit comments

Comments
 (0)