Skip to content

Commit

Permalink
Fix for stream ETAGs #8
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorium committed Nov 8, 2017
1 parent 39083e6 commit ca9d7d2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
5 changes: 4 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
### 1.0.17 - Octiober 02 2017
### 1.0.18 - November 08 2017
* Fix for stream ETAGs #8

### 1.0.17 - October 02 2017
* Fix for Owin dependency #7
* Initial conversion for .NET Standard 2.0 using Microsoft.AspNetCore.Http, not tested yet.

Expand Down
12 changes: 11 additions & 1 deletion src/Owin.Compression.Standard/CompressionModule.fs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,18 @@ module OwinCompression =
let cancellationToken = cancellationSrc.Token

let getMd5Hash (item:Stream) =
let hasPos =
if item.CanSeek && item.Position > 0L then
let tmp = item.Position
item.Position <- 0L
Some tmp
else None
use md5 = System.Security.Cryptography.MD5.Create()
BitConverter.ToString(md5.ComputeHash(item)).Replace("-","")
let res = BitConverter.ToString(md5.ComputeHash(item)).Replace("-","")
match hasPos with
| Some x when item.CanSeek -> item.Position <- x
| _ -> ()
res

let create304Response() =
if cancellationSrc<>null then cancellationSrc.Cancel()
Expand Down
12 changes: 11 additions & 1 deletion src/Owin.Compression/CompressionModule.fs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,18 @@ module OwinCompression =
let cancellationToken = cancellationSrc.Token

let getMd5Hash (item:Stream) =
let hasPos =
if item.CanSeek && item.Position > 0L then
let tmp = item.Position
item.Position <- 0L
Some tmp
else None
use md5 = System.Security.Cryptography.MD5.Create()
BitConverter.ToString(md5.ComputeHash(item)).Replace("-","")
let res = BitConverter.ToString(md5.ComputeHash(item)).Replace("-","")
match hasPos with
| Some x when item.CanSeek -> item.Position <- x
| _ -> ()
res

let create304Response() =
if cancellationSrc<>null then cancellationSrc.Cancel()
Expand Down

0 comments on commit ca9d7d2

Please sign in to comment.