Register FileBufferingReadStream for disposal

This commit is contained in:
Brennan 2015-12-22 16:01:31 -08:00
parent 1a485fadb0
commit ee804e5841
1 changed files with 3 additions and 3 deletions

View File

@ -48,9 +48,9 @@ namespace Microsoft.AspNet.Http.Internal
var body = request.Body;
if (!body.CanSeek)
{
// TODO: Register this buffer for disposal at the end of the request to ensure the temp file is deleted.
// Otherwise it won't get deleted until GC closes the stream.
request.Body = new FileBufferingReadStream(body, bufferThreshold, _getTempDirectory);
var fileStream = new FileBufferingReadStream(body, bufferThreshold, _getTempDirectory);
request.Body = fileStream;
request.HttpContext.Response.RegisterForDispose(fileStream);
}
return request;
}