Skip to content

Commit 49a2c0f

Browse files
committed
fix(request-info): initialize request body for form data tests
1 parent 539861c commit 49a2c0f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

test/Exceptionless.Tests/Platforms/AspNetCoreRequestInfoTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,13 @@ private static DefaultHttpContext CreateHttpContext(string body) {
6868
}
6969

7070
private static DefaultHttpContext CreateFormHttpContext() {
71+
const string formBody = "name=world";
72+
var bodyBytes = Encoding.UTF8.GetBytes(formBody);
7173
var context = new DefaultHttpContext();
7274
context.Request.Method = HttpMethods.Post;
7375
context.Request.ContentType = "application/x-www-form-urlencoded";
76+
context.Request.ContentLength = bodyBytes.Length;
77+
context.Request.Body = new MemoryStream(bodyBytes);
7478
context.Request.Form = new FormCollection(new Dictionary<string, StringValues> {
7579
["name"] = "world"
7680
});

0 commit comments

Comments
 (0)