Skip to content

Commit

Permalink
Don't set Content-Length, it doesn't play well with IIS
Browse files Browse the repository at this point in the history
Middleware such as dynamic compression or IIS HTTP/2 implementations can interact badly with a pre-set content-length. It's not worth it.
  • Loading branch information
lilith committed Nov 17, 2022
1 parent 4a8aa52 commit 088a712
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions core/NewModuleHelpers.cs
Expand Up @@ -48,11 +48,6 @@ internal static string GetContentTypeFromBytes(byte[] data)
/// <exception cref="InvalidOperationException"></exception>
internal static async Task ProxyToStream(Stream sourceStream, HttpResponse response)
{
if (sourceStream.CanSeek)
{
var contentLength = sourceStream.Length - sourceStream.Position;
if (contentLength > 0) response.Headers.Add("Content-Length", contentLength.ToString());
}

// We really only need 12 bytes but it would be a waste to only read that many.
const int bufferSize = 4096;
Expand Down Expand Up @@ -340,4 +335,4 @@ public async Task ProcessWithStreamCache(ILogger logger, IStreamCache streamCach
// }

}
}
}

0 comments on commit 088a712

Please sign in to comment.