Skip to content
This repository was archived by the owner on Jan 24, 2021. It is now read-only.
Merged
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
14 changes: 3 additions & 11 deletions src/Nancy/IO/RequestStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,7 @@ public RequestStream(Stream stream, long expectedLength, long thresholdLength, b

if (!this.stream.CanSeek)
{
var task =
MoveToWritableStream();

task.Wait();

if (task.IsFaulted)
{
throw new InvalidOperationException("Unable to copy stream", task.Exception);
}
this.MoveToWritableStream();
}

this.stream.Position = 0;
Expand All @@ -103,12 +95,12 @@ public RequestStream(Stream stream, long expectedLength, long thresholdLength, b
this.Dispose(false);
}

private Task MoveToWritableStream()
private void MoveToWritableStream()
{
var sourceStream = this.stream;
this.stream = new MemoryStream(BufferSize);

return sourceStream.CopyToAsync(this);
sourceStream.CopyTo(this.stream);
}

/// <summary>
Expand Down