Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Commit 4e0f0c7

Browse files
committed
#366 Rewind the request buffer after parsing the form.
1 parent 43d0b0f commit 4e0f0c7

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/Microsoft.AspNet.Http/Features/FormFeature.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ public async Task<IFormCollection> ReadFormAsync(CancellationToken cancellationT
152152
}
153153
}
154154

155+
// Rewind so later readers don't have to.
156+
_request.Body.Seek(0, SeekOrigin.Begin);
157+
155158
Form = new FormCollection(formFields, files);
156159
return Form;
157160
}

test/Microsoft.AspNet.Http.Tests/FormFeatureTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public async Task ReadFormAsync_SimpleData_ReturnsParsedFormCollection()
3232
// Assert
3333
Assert.Equal("bar", formCollection["foo"]);
3434
Assert.Equal("2", formCollection["baz"]);
35+
Assert.Equal(0, context.Request.Body.Position);
36+
Assert.True(context.Request.Body.CanSeek);
3537

3638
// Cached
3739
formFeature = context.Features.Get<IFormFeature>();

0 commit comments

Comments
 (0)