IAsyncResult result = (IAsyncResult)_request.BeginGetResponse(
new AsyncCallback(ResponseCallback), this);
ThreadPool.RegisterWaitForSingleObject(result.AsyncWaitHandle,
new WaitOrTimerCallback(TimeoutCallback), this, _timeout, true);
}
另外一个罗嗦的事情,是每个链接建立后,MS服务器会先返回一个罗嗦的license声明,srcsrv.dll会弹出一个对话框让你Accept才能继续下载。
例如你通过命令行去下载一个文件
wget --user-agent=Microsoft-Symbol-Server/9.9.9.9
Http://ReferenceSource.microsoft.com/source/.net/8.0/DEVDIV/
depot/DevDiv/releases/whidbey/REDBITS/ndp/fx/src/Misc/
InvariantComparer.cs/1/InvariantComparer.cs 会直接返回一对垃圾信息,类似
SYMSRVCOMMAND:
YESNODIALOG:
IDYES:Accept:Accept=0cf80f849aa7449e9d064ade971bd887
IDNO:Decline:Decline=0cf80f849aa7449e9d064ade971bd887
TITLE:End User License Agreement
BUTTONDESCRIPTION:Please read carefully and understand the license agreement above.
If you want to accept the license agreement, please click the “Accept” button.
TEXT:This license applies to the .NET Framework components that Microsoft makes available to you
in source code form. To print these terms, select the contents of this area and copy then paste
into an application that can print text.
MICROSOFT .NET FRAMEWORK REFERENCE LICENSE
.NET FRAMEWORK REFERENCE SOURCE CODE
This license governs use of the accompanying software. If you use the software, you accept this license.
If you do not accept the license, do not use the software
1. Definitions
The terms "reproduce," "reproduction" and "distribution" have the same meaning here as under U.S. copyright law.
解决方法很简单,直接用正则表达式找到里面一个随机生成的id,然后程序自动Accept即可,代码类似
private static Regex _accept = new Regex(@"IDYES:Accept:Accept=(w*)");