diff --git a/src/Nancy/IO/RequestStream.cs b/src/Nancy/IO/RequestStream.cs index 5273b5894c..6df04916ce 100644 --- a/src/Nancy/IO/RequestStream.cs +++ b/src/Nancy/IO/RequestStream.cs @@ -85,7 +85,12 @@ public RequestStream(Stream stream, long expectedLength, long thresholdLength, b this.stream.Position = 0; } - private Task MoveToWritableStream() + ~RequestStream() + { + this.Dispose(false); + } + + private Task MoveToWritableStream() { var tcs = new TaskCompletionSource(); @@ -213,7 +218,10 @@ protected override void Dispose(bool disposing) { if (this.isSafeToDisposeStream) { - ((IDisposable)this.stream).Dispose(); + if (this.stream != null) + { + this.stream.Dispose(); + } var fileStream = this.stream as FileStream; if (fileStream != null) diff --git a/src/Nancy/Request.cs b/src/Nancy/Request.cs index b6b9332773..aa9d92acac 100644 --- a/src/Nancy/Request.cs +++ b/src/Nancy/Request.cs @@ -48,7 +48,7 @@ public Request(string method, string path, string scheme) /// The HTTP protocol version. public Request(string method, Url url, - RequestStream body = null, + Stream body = null, IDictionary> headers = null, string ip = null, byte[] certificate = null, @@ -149,10 +149,10 @@ public string Path public dynamic Query { get; set; } /// - /// Gets a that can be used to read the incoming HTTP body + /// Gets a that can be used to read the incoming HTTP body /// - /// A object representing the incoming HTTP body. - public RequestStream Body { get; private set; } + /// A object representing the incoming HTTP body. + public Stream Body { get; private set; } /// /// Gets the request cookies.