Basic
验证的
Domain
处理
Email:zfive5@yahoo.com.cn
Author:zfive5(zhaozi)
发觉自己对网络编程真是有些末名的潜力,过去编写
basic
代理认证时,往往乎略
Domain
,最近发现
Domain
在
basic
的编码中也有体现!
如果有域值的需要这样的:
"Proxy-Authorization:Basic"+" "+Base64(Domain+“/"+UserName+":"+Password)
"WWW-Authorization:Basic"+" "+Base64(Domain+“/"+UserName+":"+Password)
如果没有域值:
"Proxy-Authorization:Basic"+" "+Base64(UserName+":"+Password)
"WWW-Authorization:Basic"+" "+Base64(UserName+":"+Password)
.NET
下的
Reflector
反编译的代码
NetworkCredential credential1 = credentials.GetCredential(httpWebRequest.ChallengedUri, BasicClient.Signature);
if (credential1 == null)
{
return null;
}
string text1 = credential1.UserName;
string text2 = credential1.Domain;
if (ValidationHelper.IsBlankString(text1))
{
return null;
}
string text3 = (!ValidationHelper.IsBlankString(text2) ? (text2 + @"/") : "") + text1 + ":" + credential1.Password;
byte[] buffer1 = BasicClient.EncodingRightGetBytes(text3);
string text4 = "Basic " + Convert.ToBase64String(buffer1);
return new Authorization(text4);
源码之下,确实可以解决一些疑问。