Skip to content

Instantly share code, notes, and snippets.

@porfirion
Last active November 9, 2018 12:52
Show Gist options
  • Save porfirion/9d295f695481538eb9acf688010377c4 to your computer and use it in GitHub Desktop.
Save porfirion/9d295f695481538eb9acf688010377c4 to your computer and use it in GitHub Desktop.
Setting http headers under f# (fsharp)
resp.Content.Headers.ContentType <- MediaTypeHeaderValue.Parse "application/json"
// OR
resp.Content.Headers.Remove("Content-Type") |> ignore
resp.Content.Headers.Add("Content-Type", "application/json")
// Because Content-Type header has HttpHeaderKind.Content and there is an exception while setting
// it on response itself:
// resp.Headers.Add("Content-Type", "application/json")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment