question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RequestDecompression middleware

See original GitHub issue

The same way we have a ResponseCompression middleware we should have a RequestDecompression one that automatically decompress the requests containing Content-Encoding with supported formats (gzip, deflate, brotli, …). Based on the same extensible compression factories.

Scenario: a client sends files to a server using gzip compressed streams. The developer of the server application doesn’t have to care about how to decrompress the body.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:16 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
halter73commented, May 16, 2022

API Review:

We think this is filling a gap. People would be surprised if the RequestSizeLimitAttribute works but DisableRequestSizeLimitAttribute doesn’t. Approved.

namespace Microsoft.AspNetCore.Http.Metadata;

public interface IRequestSizeLimitMetadata
{
-    public long MaxRequestBodySize { get; }
+    public long? MaxRequestBodySize { get; }
}

namespace Microsoft.AspNetCore.Mvc;

- public class DisableRequestSizeLimitAttribute : Attribute, IFilterFactory, IOrderedFilter
+ public class DisableRequestSizeLimitAttribute : Attribute, IFilterFactory, IOrderedFilter, IRequestSizeLimitMetadata

We should update our docs to make it clear that disabling request size limits can be a security concern, particularly if the request body is being buffered. @david-acker Do you mind updating the doc comments for DisableRequestSizeLimitAttribute with a remark to this effect in your PR when you add the IRequestSizeLimitMetadata implementation to DisableRequestSizeLimitAttribute?

1reaction
pranavkmcommented, Feb 28, 2022

API review:

Approved. Update the IRequestDecompressionProvider to return the Stream instead of the provider:

+ public interface IRequestDecompressionProvider
+ {
+     Stream? GetDecompressionStream(HttpContext context);
+ }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Request decompression in ASP.NET Core
Request decompression in ASP.NET Core · Enables API endpoints to accept requests with compressed content. · Uses the matching provider to wrap the ......
Read more >
How to use request decompression in ASP.NET Core 7
ASP.NET Core 7 includes a new request decompression middleware that allows endpoints to accept requests that have compressed content. This ...
Read more >
ASP.NET Core request decompression middleware
The middleware supports decompressing a request with multiple encodings applied (up to 16). The middleware supports a custom additional handler for an ...
Read more >
Request decompression in ASP.NET Core
Request decompression in ASP.NET Core · Occurs when the body of the request is being read. That is, decompression occurs at the endpoint...
Read more >
Request content decompression in ASP.Net Core
The request decompression middleware is added using the UseRequestDecompression extension method on IApplicationBuilder and the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found