Open
Description
I've opened this issue to discuss the idea that I've mentioned in here and here now that Request Decompression Middleware is merged.
At the moment IDecompressionProvider
is creating a decompression stream and the middleware creates a SizeLimitedStream
which wraps the other one. We could reduce this two streams into one if the IDecompressionProvider
returns a stream that also handle size limit check, and the middleware only create SizeLimitedStream
if the returned stream from the IDecompressionProvider
is not marked with IDontNeedWrapper
interface.
+internal interface IDontNeedWrapper {}
+internal sealed class GZipRequestDecompressionBody : GZipStream, IDontNeedWrapper {}
+internal sealed class DeflateRequestDecompressionBody : DeflateStream , IDontNeedWrapper {}
+internal sealed class BrotliRequestDecompressionBody : BrotliStream, IDontNeedWrapper {}
The new types for this change are all private, so there's no new public types. By doing this we would reduce one allocation per requests when request body is compressed by GZip
, Deflate
or Brotli
.