-
-
Notifications
You must be signed in to change notification settings - Fork 226
Description
In #4315 we may have introduced a problem when/if other middleware wants to read the request body:
sentry-dotnet/src/Sentry/Extensibility/BaseRequestPayloadExtractor.cs
Lines 26 to 31 in 300248f
| if (!request.Body.CanSeek) | |
| { | |
| // When RequestDecompression is enabled, the RequestDecompressionMiddleware will store a SizeLimitedStream | |
| // in the request body after decompression. Seek operations throw an exception, but we can still read the stream | |
| return DoExtractPayLoad(request); | |
| } |
The new middleware that we vendored in is getting an IRequestDecompressionProvider injected from DI via the constructor. That gets registered by the AddRequestDecompression service extension. The stream that this returns doesn't typically support seek (decompression streams are typically forward only). For example GZipStream.CanSeek returns false in all cases.
A naive solution would be to read the decompression stream into a memory stream and store the results back on the RequestBody as a MemoryStream (which does support seek).
In theory, this shouldn't be necessary. We call EnableBuffering:
| context.Request.EnableBuffering(); |
Looking at the implementation for that extension this should handle all of this automatically for us.
So why is EnableBuffering not doing what we expect it to?
Metadata
Metadata
Assignees
Labels
Projects
Status