Skip to content

Ra/request decompression middleware/david acker#26763

Merged
Rick-Anderson merged 8 commits into
mainfrom
ra/requestDecompression-middleware/david-acker
Aug 19, 2022
Merged

Ra/request decompression middleware/david acker#26763
Rick-Anderson merged 8 commits into
mainfrom
ra/requestDecompression-middleware/david-acker

Conversation

@Rick-Anderson
Copy link
Copy Markdown
Contributor

@Rick-Anderson Rick-Anderson commented Aug 17, 2022

Fixes #26541
moved from #26761

Internal review URL

Public review of the doc build:

  • download the HTML files
  • unzip
  • view HTML file in a browser.
  • For links outside the doc, remove the review. from URL.

@Rick-Anderson
Copy link
Copy Markdown
Contributor Author

@david-acker please review my commit. That's a quick pass, I'll tweak it but you'll get an idea of my changes.

@Rick-Anderson Rick-Anderson marked this pull request as ready for review August 17, 2022 23:02
@david-acker
Copy link
Copy Markdown
Member

@Rick-Anderson Looks great! Thanks for cleaning this up.

@Rick-Anderson Rick-Anderson requested a review from Tratcher August 18, 2022 01:23
Decompression:

* Occurs when the body of the request is being read. That is, decompression occurs at the endpoint on model binding. The request body is not decompressed eagerly.
* When attempting to read the decompressed request body, if the compressed data is invalid for the specified `Content-Encoding`, an exception is thrown.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What kind of exception? Since this is Stream, only a few types of exceptions are expected, like IOException.

Copy link
Copy Markdown
Member

@david-acker david-acker Aug 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the exceptions thrown by the underlying decompression stream implementations used by the default providers:

Brotli (BrotliStream):

System.InvalidOperationException: Decoder ran into invalid data.

Deflate (DeflateStream):

System.IO.InvalidDataException: The archive entry was compressed using an unsupported compression method.

GZip (GZipStream):

System.IO.InvalidDataException: The archive entry was compressed using an unsupported compression method.

The maximum request size for an endpoint is set by:

* <xref:Microsoft.AspNetCore.Http.Metadata.IRequestSizeLimitMetadata.MaxRequestBodySize?displayProperty=nameWithType>, such as <xref:Microsoft.AspNetCore.Mvc.RequestSizeLimitAttribute> or <xref:Microsoft.AspNetCore.Mvc.DisableRequestSizeLimitAttribute> for MVC endpoints.
* If the preceding API's aren't applied, the global server size limit specified by <xref:Microsoft.AspNetCore.Http.Features.IHttpMaxRequestBodySizeFeature.MaxRequestBodySize?displayProperty=nameWithType> is used.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rick-Anderson Rick-Anderson merged commit 4688bc9 into main Aug 19, 2022
@Rick-Anderson Rick-Anderson deleted the ra/requestDecompression-middleware/david-acker branch August 19, 2022 02:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET 7: Request decompression middleware

3 participants