Skip to content

Commit

Permalink
Do not close http body stream. Fixes #12
Browse files Browse the repository at this point in the history
  • Loading branch information
olsh committed Apr 3, 2019
1 parent 711daa2 commit 081c9e5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,16 @@ public DynamicHttpContextRequest(HttpContext context)

// ReSharper disable once ExceptionNotDocumented
_context.Request.Body.Position = 0;
using (var bodyReader = new StreamReader(_context.Request.Body))
using (var bodyReader = new StreamReader(_context.Request.Body, Encoding.UTF8, false, 1024, true))
{
// ReSharper disable once ExceptionNotDocumented
var body = bodyReader.ReadToEnd();

_stream = new MemoryStream(Encoding.UTF8.GetBytes(body));
}

// Reset the request body stream position so the next middleware can read it
context.Request.Body.Position = 0;
}

public string ContentType => _context.Request.ContentType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>A Sentry sink for Serilog</Description>
<VersionPrefix>2.4.1</VersionPrefix>
<VersionPrefix>2.4.2</VersionPrefix>
<Authors>Oleg Shevchenko</Authors>
<TargetFrameworks>net451;netstandard2.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down

0 comments on commit 081c9e5

Please sign in to comment.