Last active
August 29, 2015 14:08
-
-
Save kjnilsson/b9985c8b37c391c053c2 to your computer and use it in GitHub Desktop.
How do I make this properly async?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ContentLengthHandler() = | |
inherit DelegatingHandler () | |
override __.SendAsync (request, token) = | |
let resp = base.SendAsync(request, token).Result //GAH | |
match resp.Content with | |
| :? ObjectContent as oc -> | |
let s = oc.ReadAsStreamAsync().Result //GAH | |
resp.Content <- new StreamContent(s) | |
resp.Content.Headers.ContentLength <- Nullable (int64 s.Length) | |
Task.FromResult resp | |
| _ -> | |
Task.FromResult resp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment