Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Review feedback
  • Loading branch information
jamescrosswell committed Jul 8, 2025
commit 76ebf4ffb9d16824c56e2222410077e4d1bef284
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private void HandleException(Exception e)
const string description =
"An exception was captured and then re-thrown, when attempting to decompress the request body." +
"The web server likely returned a 5xx error code as a result of this exception.";
e.SetSentryMechanism("RequestDecompressionMiddleware", description, handled: false);
e.SetSentryMechanism(nameof(RequestDecompressionMiddleware), description, handled: false);
_hub.CaptureException(e);
ExceptionDispatchInfo.Capture(e).Throw();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Sentry.AspNetCore/SentryAspNetCoreOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ internal void SetEnvironment(IWebHostEnvironment hostingEnvironment)

if (hostingEnvironment.IsProduction())
{
Environment = Sentry.Internal.Constants.ProductionEnvironmentSetting;
Environment = Internal.Constants.ProductionEnvironmentSetting;
}
else if (hostingEnvironment.IsStaging())
{
Environment = Sentry.Internal.Constants.StagingEnvironmentSetting;
Environment = Internal.Constants.StagingEnvironmentSetting;
}
else if (hostingEnvironment.IsDevelopment())
{
Environment = Sentry.Internal.Constants.DevelopmentEnvironmentSetting;
Environment = Internal.Constants.DevelopmentEnvironmentSetting;
}
else
{
Expand Down
22 changes: 10 additions & 12 deletions src/Sentry/Extensibility/BaseRequestPayloadExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,22 @@ public abstract class BaseRequestPayloadExtractor : IRequestPayloadExtractor
return null;
}

// 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
var originalPosition = request.Body.CanSeek ? request.Body.Position : 0;
try
if (!request.Body.CanSeek)
{
if (request.Body.CanSeek)
{
request.Body.Position = 0;
}
// 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);
}

var originalPosition = request.Body.Position;
try
{
request.Body.Position = 0;
return DoExtractPayLoad(request);
}
finally
{
if (request.Body.CanSeek)
{
request.Body.Position = originalPosition;
}
request.Body.Position = originalPosition;
}
}

Expand Down