internal FtpWebRequest(Uri uri)
{
if (NetEventSource.IsEnabled) NetEventSource.Info(this, uri);
if ((object)uri.Scheme != (object)Uri.UriSchemeFtp)
throw new ArgumentOutOfRangeException(nameof(uri));
_timerCallback = new TimerThread.Callback(TimerCallback);
_syncObject = new object();
NetworkCredential networkCredential = null;
_uri = uri;
_methodInfo = FtpMethodInfo.GetMethodInfo(WebRequestMethods.Ftp.DownloadFile);
if (_uri.UserInfo != null && _uri.UserInfo.Length != 0)
{
string userInfo = _uri.UserInfo;
string username = userInfo;
string password = "";
int index = userInfo.IndexOf(':');
if (index != -1)
{
username = Uri.UnescapeDataString(userInfo.Substring(0, index));
index++; // skip ':'
password = Uri.UnescapeDataString(userInfo.Substring(index, userInfo.Length - index));
}
networkCredential = new NetworkCredential(username, password);
}
if (networkCredential == null)
{
networkCredential = s_defaultFtpNetworkCredential;
}
_authInfo = networkCredential;
}