简体   繁体   中英

Why does using the default proxy credentials not result in an automatic second http request following a 407 response?

I have set up fiddler as a proxy server requiring authentication following these instructions .

When I explicitly set the credentials I've set in Fiddler in my HttpClientHandler :

this.Proxy = WebRequest.DefaultWebProxy;
this.Proxy.Credentials = new NetworkCredential("sweet name", "sweet password");

Then in Fiddler I get 2 http requests, a 407 and an automatic 200, and the request succeeds:

407 和 200 响应

However, when I try use the default credentials:

this.Proxy = WebRequest.DefaultWebProxy;
this.Proxy.Credentials = CredentialCache.DefaultCredentials;

Then in Fiddler I only get one request, a 407, and the request fails:

在此处输入图片说明

Why is there no automatic retry with the default credentials like there is when I explicitly set the proxy credentials?

As pointed out by @Robert in a comment, the documentation says:

The DefaultCredentials property applies only to NTLM, negotiate, and Kerberos-based authentication.

Hence it makes sense that there is no automatic second http request following a 407 response when the proxy uses basic authentication.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM