Http.fs
Http.fs copied to clipboard
Ability to use NTLM credentials appears to have been removed
I was looking for the ability to use NTLM credentials and 6e0a414
looked promising, however it seems this code has been removed when the library was migrated to use HttpClient instead of HttpWebRequest.
It looks to be a case of just providing the ability to set UseDefaultCredentials = true
in Http.fsL641. (Sorry - I don't have the ability to branch the source or do a PR from here...)
You can do this now by creating a HttpClientHandler with the appropriate settings:
let ntlmHttpClient = new HttpClient(new HttpClientHandler(UseDefaultCredentials = true))
let createRequestWithNtlm (method: HttpMethod) (url: string) =
Uri (url) |> Request.createWithClient ntlmHttpClient method
let request =
"http://requiresNtml"
|> createRequestWithNtlm Get
|> Request.etc....
It's just important to remember that the HttpClient itself needs to be reused and not created/disposed per-request. You could do that at your application root and pass it around as a func / partially applied, or just have it as I've done above and re-use the createRequestWithNtlm
function.