Skip to content
This repository was archived by the owner on Jan 24, 2021. It is now read-only.

Backport #2512 to 1.x-WorkingBranch #2616

Open
wants to merge 2 commits into
base: 1.x-WorkingBranch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/Nancy/IO/RequestStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ public RequestStream(Stream stream, long expectedLength, long thresholdLength, b
this.stream.Position = 0;
}

private Task<object> MoveToWritableStream()
~RequestStream()
{
this.Dispose(false);
}

private Task MoveToWritableStream()
{
var tcs = new TaskCompletionSource<object>();

Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/Nancy/Request.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public Request(string method, string path, string scheme)
/// <param name="protocolVersion">The HTTP protocol version.</param>
public Request(string method,
Url url,
RequestStream body = null,
Stream body = null,
IDictionary<string, IEnumerable<string>> headers = null,
string ip = null,
byte[] certificate = null,
Expand Down Expand Up @@ -149,10 +149,10 @@ public string Path
public dynamic Query { get; set; }

/// <summary>
/// Gets a <see cref="RequestStream"/> that can be used to read the incoming HTTP body
/// Gets a <see cref="Stream"/> that can be used to read the incoming HTTP body
/// </summary>
/// <value>A <see cref="RequestStream"/> object representing the incoming HTTP body.</value>
public RequestStream Body { get; private set; }
/// <value>A <see cref="Stream"/> object representing the incoming HTTP body.</value>
public Stream Body { get; private set; }

/// <summary>
/// Gets the request cookies.
Expand Down