Skip to content

Commit

Permalink
Core - ResourceHandler set Stream.Position = 0 and if CanSeek
Browse files Browse the repository at this point in the history
- Prior to version 75 the Stream.Position was set to 0 before the ResourceHandler would read the Stream.
This restores that behaviour.
- Minor refactor of if statement for Stream.Can seek, only override ResponseLength with Stream.Length of not already set

Resolves #2903
  • Loading branch information
amaitland committed Jan 22, 2020
1 parent 731c626 commit 1155ef1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions CefSharp/ResourceHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,17 @@ void IResourceHandler.GetResponseHeaders(IResponse response, out long responseLe
{
responseLength = ResponseLength.Value;
}
else if (Stream != null && Stream.CanSeek)

if (Stream != null && Stream.CanSeek)
{
//If no ResponseLength provided then attempt to infer the length
responseLength = Stream.Length;
//ResponseLength property has higher precedence over Stream.Length
if (ResponseLength == null || responseLength == 0)
{
//If no ResponseLength provided then attempt to infer the length
responseLength = Stream.Length;
}

Stream.Position = 0;
};
}

Expand Down

0 comments on commit 1155ef1

Please sign in to comment.