Skip to content

Request.Body is not decompressed when Content-Encoding: gzip, even with ASP.NET Core’s UseRequestDecompression() #4312

@slipdef

Description

@slipdef

Package

Sentry

.NET Flavor

.NET Core

.NET Version

9.0.6

OS

Windows

OS Version

11

Development Environment

Visual Studio v17.x

SDK Version

3.23.1

Self-Hosted Sentry Version

No response

Workload Versions


aspire 8.2.2/8.0.100 VS 17.14.36212.18

When using Sentry SDK in an ASP.NET Core app with UseRequestDecompression(), HTTP requests with Content-Encoding: gzip are still logged with their raw compressed body in Sentry.

This occurs because UseRequestDecompression() only integrates with model binding and does not replace or decompress HttpContext.Request.Body, which Sentry reads directly.

Steps to Reproduce

Configure ASP.NET Core pipeline with UseRequestDecompression() early.

Enable Sentry automatic request body logging.

Send a POST request with Content-Encoding: gzip and gzipped JSON body.

Trigger an exception.

Check Sentry issue – Request.Body is unreadable gzip binary.

Expected Result

Sentry should log the decompressed request body when UseRequestDecompression() is enabled and the request has Content-Encoding: gzip.

Actual Result

Image

Metadata

Metadata

Labels

.NETPull requests that update .net codeBugSomething isn't working

Projects

Status

Done

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions