-
-
Notifications
You must be signed in to change notification settings - Fork 143
Fixes request-info collection across the ASP.NET Core / ASP.NET (System.Web) / WebApi platform integrations to avoid reading POST bodies for handled errors, #347
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
468ba0f
chore(ci): upgrade workflow actions and sdk setup
niemyjski c1193d9
fix(request-info): avoid reading handled post data
niemyjski 5f1c840
chore: update .NET SDK version to 10.0.100
niemyjski 539861c
fix(request-info): restore stream position and update to .NET 10
niemyjski 49a2c0f
fix(request-info): initialize request body for form data tests
niemyjski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "sdk": { | ||
| "version": "8.0.100", | ||
| "version": "9.0.100", | ||
|
niemyjski marked this conversation as resolved.
Outdated
|
||
| "rollForward": "latestMinor" | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
test/Exceptionless.Tests/Platforms/AspNetCoreRequestInfoTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| using System.IO; | ||
| using System.Text; | ||
| using Exceptionless; | ||
| using Exceptionless.Dependency; | ||
| using Microsoft.AspNetCore.Http; | ||
| using Xunit; | ||
|
|
||
| namespace Exceptionless.Tests.Platforms { | ||
| public class AspNetCoreRequestInfoTests { | ||
| [Fact] | ||
| public void GetRequestInfo_DoesNotReadPostData_ForHandledErrors() { | ||
| var context = CreateHttpContext("hello=world"); | ||
|
niemyjski marked this conversation as resolved.
|
||
| var config = new ExceptionlessConfiguration(DependencyResolver.CreateDefault()); | ||
|
|
||
| var requestInfo = context.GetRequestInfo(config); | ||
|
|
||
| Assert.NotNull(requestInfo); | ||
| Assert.Null(requestInfo.PostData); | ||
| Assert.Equal(0L, context.Request.Body.Position); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void GetRequestInfo_ReadsAndRestoresPostData_ForUnhandledErrors() { | ||
| const string body = "{\"hello\":\"world\"}"; | ||
| var context = CreateHttpContext(body); | ||
| var config = new ExceptionlessConfiguration(DependencyResolver.CreateDefault()); | ||
|
|
||
| context.Request.Body.Position = 5; | ||
|
|
||
| var requestInfo = context.GetRequestInfo(config, isUnhandledError: true); | ||
|
|
||
| Assert.NotNull(requestInfo); | ||
| Assert.Equal(body, Assert.IsType<string>(requestInfo.PostData)); | ||
| Assert.Equal(5L, context.Request.Body.Position); | ||
| } | ||
|
niemyjski marked this conversation as resolved.
|
||
|
|
||
| private static DefaultHttpContext CreateHttpContext(string body) { | ||
| var bodyBytes = Encoding.UTF8.GetBytes(body); | ||
| var context = new DefaultHttpContext(); | ||
| context.Request.Method = HttpMethods.Post; | ||
| context.Request.ContentType = "application/json"; | ||
| context.Request.Body = new MemoryStream(bodyBytes); | ||
| context.Request.ContentLength = bodyBytes.Length; | ||
| return context; | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.