-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RequestDecompression middleware #40080
Comments
Prior ask: #30544 |
Thanks for contacting us. We're moving this issue to the |
I'd be interested in helping out with this. This should follow the same pattern that the |
@david-acker I think it should do the same thing, yes. Go for it! Since nobody would do it for now. I would use it then instead of doing it my controllers: https://github.com/dotnet/crank/blob/main/src/Microsoft.Crank.Agent/Controllers/JobsController.cs#L389 |
I would be glad to offer my help as well if needed: I've been using my own middleware implementation for a few years: |
@sebastienros From a practical perspective, does it make sense to support decompressing requests that have multiple Content-Encodings applied (e.g. compressed with Brotli and then GZip)? I'd be happy to add this if you think it's worthwhile, but I just wanted to confirm first. I'll put a draft PR with the working implementation soon so I can get some feedback. |
Is that something people actually do? They'd get minimal returns on the second pass. We don't support this on response compression. I wouldn't worry about it for the first implementation. |
That was my thought as well. I saw this mentioned in RFC 2616 and a few other places online (not with any examples of actual implementations though), but I figured I'd ask just to be sure. |
API Review: namespace Microsoft.AspNetCore.Http.Metadata;
+ public interface IRequestSizeLimitMetadata
+ {
+ public long MaxRequestBodySize { get; }
+ }
+ namespace Microsoft.AspNetCore.RequestDecompression;
+ public interface IDecompressionProvider
+ {
+ Stream GetDecompressionStream(Stream stream);
+ }
+ public interface IRequestDecompressionProvider
+ {
+ IDecompressionProvider? GetDecompressionProvider(HttpContext context);
+ }
+ public sealed class RequestDecompressionOptions
+ {
+ public IDictionary<string, IDecompressionProvider> DecompressionProviders { get; }
+ }
namespace Microsoft.AspNetCore.Builder;
+ public static class RequestDecompressionBuilderExtensions
+ {
+ public static IApplicationBuilder UseRequestDecompression(this IApplicationBuilder builder);
+ }
namespace Microsoft.Extensions.DependencyInjection;
+ public static class RequestDecompressionServiceExtensions
+ {
+ public static IServiceCollection AddRequestDecompression(this IServiceCollection services);
+ public static IServiceCollection AddRequestDecompression(this IServiceCollection services, Action<RequestDecompressionOptions> configureOptions);
+ }
namespace Microsoft.AspNetCore.Mvc;
- public class RequestSizeLimitAttribute : Attribute, IFilterFactory, IOrderedFilter
+ public class RequestSizeLimitAttribute : Attribute, IFilterFactory, IOrderedFilter, IRequestSizeLimitMetadata |
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
API review: Approved. Update the + public interface IRequestDecompressionProvider
+ {
+ Stream? GetDecompressionStream(HttpContext context);
+ } |
We should also support the 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 Context: #40279 (comment) |
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
API Review: We think this is filling a gap. People would be surprised if the 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 |
I've added the following as a remark to the doc comments for
Let me know if there's anything that you'd like me to add or change. |
this would be extremely useful! |
The same way we have a
ResponseCompression
middleware we should have aRequestDecompression
one that automatically decompress the requests containingContent-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.
The text was updated successfully, but these errors were encountered: