Http.fs icon indicating copy to clipboard operation
Http.fs copied to clipboard

Ability to use NTLM credentials appears to have been removed

Open idlem1nd opened this issue 6 years ago • 1 comments

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...)

idlem1nd avatar Apr 27 '18 12:04 idlem1nd

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.

seanamos avatar Apr 30 '18 07:04 seanamos