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

Commit ee804e5

Browse files
committed
Register FileBufferingReadStream for disposal
1 parent 1a485fa commit ee804e5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Microsoft.AspNet.Http/BufferingHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ public static HttpRequest EnableRewind(this HttpRequest request, int bufferThres
4848
var body = request.Body;
4949
if (!body.CanSeek)
5050
{
51-
// TODO: Register this buffer for disposal at the end of the request to ensure the temp file is deleted.
52-
// Otherwise it won't get deleted until GC closes the stream.
53-
request.Body = new FileBufferingReadStream(body, bufferThreshold, _getTempDirectory);
51+
var fileStream = new FileBufferingReadStream(body, bufferThreshold, _getTempDirectory);
52+
request.Body = fileStream;
53+
request.HttpContext.Response.RegisterForDispose(fileStream);
5454
}
5555
return request;
5656
}

0 commit comments

Comments
 (0)