System.Net.Http.WinHttpHandler.WinHttpHandler.SetRequestHandleCredentialsOptions C# (CSharp) Method

SetRequestHandleCredentialsOptions() private method

private SetRequestHandleCredentialsOptions ( WinHttpRequestState state ) : void
state WinHttpRequestState
return void
        private void SetRequestHandleCredentialsOptions(WinHttpRequestState state)
        {
            // By default, WinHTTP sets the default credentials policy such that it automatically sends default credentials
            // (current user's logged on Windows credentials) to a proxy when needed (407 response). It only sends
            // default credentials to a server (401 response) if the server is considered to be on the Intranet.
            // WinHttpHandler uses a more granual opt-in model for using default credentials that can be different between
            // proxy and server credentials. It will explicitly allow default credentials to be sent at a later stage in
            // the request processing (after getting a 401/407 response) when the proxy or server credential is set as
            // CredentialCache.DefaultNetworkCredential. For now, we set the policy to prevent any default credentials
            // from being automatically sent until we get a 401/407 response.
            _authHelper.ChangeDefaultCredentialsPolicy(
                state.RequestHandle,
                Interop.WinHttp.WINHTTP_AUTH_TARGET_SERVER,
                allowDefaultCredentials:false);
        }