diff --git a/Unosquare.Labs.EmbedIO.Samples/StaticFilesSample.cs b/Unosquare.Labs.EmbedIO.Samples/StaticFilesSample.cs
index 006a25a31..b30b03a45 100644
--- a/Unosquare.Labs.EmbedIO.Samples/StaticFilesSample.cs
+++ b/Unosquare.Labs.EmbedIO.Samples/StaticFilesSample.cs
@@ -4,7 +4,7 @@
using Unosquare.Labs.EmbedIO.Modules;
///
- ///
+ /// Sample helper
///
public static class StaticFilesSample
{
@@ -23,7 +23,7 @@ public static string HtmlRootPath
// This lets you edit the files without restarting the server.
return Path.GetFullPath(Path.Combine(assemblyPath, "..\\..\\html"));
#else
- // This is when you have deployed ythe server.
+ // This is when you have deployed the server.
return Path.Combine(assemblyPath, "html");
#endif
}
@@ -38,7 +38,6 @@ public static void Setup(WebServer server)
server.RegisterModule(new StaticFilesModule(HtmlRootPath));
// The static files module will cache small files in ram until it detects they have been modified.
server.Module().UseRamCache = false;
- server.Module().UseGzip = false;
server.Module().DefaultExtension = ".html";
// We don't need to add the line below. The default document is always index.html.
//server.Module().DefaultDocument = "index.html";
diff --git a/Unosquare.Labs.EmbedIO/Modules/StaticFilesModule.cs b/Unosquare.Labs.EmbedIO/Modules/StaticFilesModule.cs
index 7981befcc..ae4bca20b 100644
--- a/Unosquare.Labs.EmbedIO/Modules/StaticFilesModule.cs
+++ b/Unosquare.Labs.EmbedIO/Modules/StaticFilesModule.cs
@@ -19,6 +19,11 @@ public class StaticFilesModule : WebModuleBase
///
private const int ChuckSize = 256*1024;
+ ///
+ /// The maximum gzip input length
+ ///
+ private const int MaxGzipInputLength = 4*1024*1024;
+
private readonly Dictionary m_VirtualPaths =
new Dictionary(StringComparer.InvariantCultureIgnoreCase);
@@ -298,7 +303,9 @@ private bool HandleGet(HttpListenerContext context, WebServer server, bool sendB
}
else
{
- if (UseGzip && context.RequestHeader(Constants.HeaderAcceptEncoding).Contains(Constants.HeaderCompressionGzip))
+ if (UseGzip &&
+ context.RequestHeader(Constants.HeaderAcceptEncoding).Contains(Constants.HeaderCompressionGzip) &&
+ buffer.Length < MaxGzipInputLength)
{
// Perform compression if available
buffer = buffer.Compress();