如何解决为什么使用默认代理凭据不会在407响应后导致第二个自动http请求?
我已将提琴手设置为需要在these instructions之后进行身份验证的代理服务器。
当我明确设置我在HttpClientHandler
中的Fiddler中设置的凭据时:
this.Proxy = WebRequest.DefaultWebProxy;
this.Proxy.Credentials = new NetworkCredential("sweet name","sweet password");
然后在Fiddler中,我收到2个http请求,一个407和一个自动200,请求成功:
但是,当我尝试使用默认凭据时:
this.Proxy = WebRequest.DefaultWebProxy;
this.Proxy.Credentials = CredentialCache.DefaultCredentials;
然后在Fiddler中,我只收到一个请求,一个407,而请求失败:
为什么没有像我显式设置代理凭据时那样使用默认凭据自动重试?
解决方法
@Robert在评论中指出,the documentation说:
The DefaultCredentials property applies only to NTLM,negotiate,and Kerberos-based authentication.
因此,当代理使用基本身份验证时,在407响应之后没有自动第二个http请求是有道理的。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。