Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ BuildCommandsList()

override PipelineEntry[] System.Net.FtpControlStream.BuildCommandsList ( WebRequest req)
inlineprotectedvirtual

Reimplemented from System.Net.CommandStream.

Definition at line 406 of file FtpControlStream.cs.

407 {
408 bool flag = false;
409 FtpWebRequest ftpWebRequest = (FtpWebRequest)req;
410 if (System.Net.NetEventSource.Log.IsEnabled())
411 {
412 System.Net.NetEventSource.Info(this, null, "BuildCommandsList");
413 }
414 _responseUri = ftpWebRequest.RequestUri;
416 if (ftpWebRequest.EnableSsl && !base.UsingSecureStream)
417 {
418 list.Add(new PipelineEntry(FormatFtpCommand("AUTH", "TLS")));
419 flag = true;
420 }
421 if (flag)
422 {
423 _loginDirectory = null;
426 _currentTypeSetting = string.Empty;
427 if (_loginState == FtpLoginState.LoggedIn)
428 {
429 _loginState = FtpLoginState.LoggedInButNeedsRelogin;
430 }
431 }
432 if (_loginState != FtpLoginState.LoggedIn)
433 {
434 Credentials = ftpWebRequest.Credentials.GetCredential(ftpWebRequest.RequestUri, "basic");
437 string text = string.Empty;
438 string text2 = string.Empty;
439 if (Credentials != null)
440 {
442 string domain = Credentials.Domain;
443 if (!string.IsNullOrEmpty(domain))
444 {
445 text = domain + "\\" + text;
446 }
448 }
449 if (text.Length == 0 && text2.Length == 0)
450 {
451 text = "anonymous";
452 text2 = "anonymous@";
453 }
454 list.Add(new PipelineEntry(FormatFtpCommand("USER", text)));
455 list.Add(new PipelineEntry(FormatFtpCommand("PASS", text2), PipelineEntryFlags.DontLogParameter));
456 if (ftpWebRequest.EnableSsl && !base.UsingSecureStream)
457 {
458 list.Add(new PipelineEntry(FormatFtpCommand("PBSZ", "0")));
459 list.Add(new PipelineEntry(FormatFtpCommand("PROT", "P")));
460 }
461 list.Add(new PipelineEntry(FormatFtpCommand("OPTS", "utf8 on")));
462 list.Add(new PipelineEntry(FormatFtpCommand("PWD", null)));
463 }
465 if (ftpWebRequest.MethodInfo.HasFlag(FtpMethodFlags.DoesNotTakeParameter))
466 {
467 pathOption = GetPathOption.AssumeNoFilename;
468 }
469 else if (ftpWebRequest.MethodInfo.HasFlag(FtpMethodFlags.ParameterIsDirectory))
470 {
471 pathOption = GetPathOption.AssumeFilename;
472 }
474 if (filename.Length == 0 && ftpWebRequest.MethodInfo.HasFlag(FtpMethodFlags.TakesParameter))
475 {
476 throw new WebException(System.SR.net_ftp_invalid_uri);
477 }
479 {
480 list.Add(new PipelineEntry(FormatFtpCommand("CWD", _loginDirectory), PipelineEntryFlags.UserCommand));
482 }
483 if (ftpWebRequest.MethodInfo.HasFlag(FtpMethodFlags.MustChangeWorkingDirectoryToPath) && directory.Length > 0)
484 {
485 list.Add(new PipelineEntry(FormatFtpCommand("CWD", directory), PipelineEntryFlags.UserCommand));
487 }
488 if (!ftpWebRequest.MethodInfo.IsCommandOnly)
489 {
490 string text3 = (ftpWebRequest.UseBinary ? "I" : "A");
492 {
493 list.Add(new PipelineEntry(FormatFtpCommand("TYPE", text3)));
495 }
496 if (ftpWebRequest.UsePassive)
497 {
498 string command = ((base.ServerAddress.AddressFamily == AddressFamily.InterNetwork || base.ServerAddress.IsIPv4MappedToIPv6) ? "PASV" : "EPSV");
499 list.Add(new PipelineEntry(FormatFtpCommand(command, null), PipelineEntryFlags.CreateDataConnection));
500 }
501 else
502 {
503 string command2 = ((base.ServerAddress.AddressFamily == AddressFamily.InterNetwork || base.ServerAddress.IsIPv4MappedToIPv6) ? "PORT" : "EPRT");
506 }
507 if (ftpWebRequest.ContentOffset > 0)
508 {
509 list.Add(new PipelineEntry(FormatFtpCommand("REST", ftpWebRequest.ContentOffset.ToString(CultureInfo.InvariantCulture))));
510 }
511 }
512 PipelineEntryFlags pipelineEntryFlags = PipelineEntryFlags.UserCommand;
513 if (!ftpWebRequest.MethodInfo.IsCommandOnly)
514 {
515 pipelineEntryFlags |= PipelineEntryFlags.GiveDataStream;
516 if (!ftpWebRequest.UsePassive)
517 {
518 pipelineEntryFlags |= PipelineEntryFlags.CreateDataConnection;
519 }
520 }
521 if (ftpWebRequest.MethodInfo.Operation == FtpOperation.Rename)
522 {
523 string text4 = ((directory.Length == 0) ? string.Empty : (directory + "/"));
524 list.Add(new PipelineEntry(FormatFtpCommand("RNFR", text4 + filename), pipelineEntryFlags));
525 string parameter = ((string.IsNullOrEmpty(ftpWebRequest.RenameTo) || !ftpWebRequest.RenameTo.StartsWith("/", StringComparison.OrdinalIgnoreCase)) ? (text4 + ftpWebRequest.RenameTo) : ftpWebRequest.RenameTo);
526 list.Add(new PipelineEntry(FormatFtpCommand("RNTO", parameter), pipelineEntryFlags));
527 }
528 else if (ftpWebRequest.MethodInfo.HasFlag(FtpMethodFlags.DoesNotTakeParameter))
529 {
530 list.Add(new PipelineEntry(FormatFtpCommand(ftpWebRequest.Method, string.Empty), pipelineEntryFlags));
531 }
532 else if (ftpWebRequest.MethodInfo.HasFlag(FtpMethodFlags.MustChangeWorkingDirectoryToPath))
533 {
535 }
536 else
537 {
538 list.Add(new PipelineEntry(FormatFtpCommand(ftpWebRequest.Method, path), pipelineEntryFlags));
539 }
540 list.Add(new PipelineEntry(FormatFtpCommand("QUIT", null)));
541 return list.ToArray();
542 }
void Add(TKey key, TValue value)
static CultureInfo InvariantCulture
string GetPortCommandLine(FtpWebRequest request)
void CreateFtpListenerSocket(FtpWebRequest request)
static void GetPathInfo(GetPathOption pathOption, Uri uri, out string path, out string directory, out string filename)
string FormatFtpCommand(string command, string parameter)
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
static string net_ftp_invalid_uri
Definition SR.cs:94
Definition SR.cs:7

References System.Net.FtpControlStream._currentTypeSetting, System.Net.FtpControlStream._establishedServerDirectory, System.Net.FtpControlStream._exitMessage, System.Net.FtpControlStream._loginDirectory, System.Net.FtpControlStream._loginState, System.Net.FtpControlStream._requestedServerDirectory, System.Net.FtpControlStream._responseUri, System.Net.FtpControlStream._welcomeMessage, System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.Net.FtpControlStream.CreateFtpListenerSocket(), System.Net.FtpControlStream.Credentials, System.Net.NetworkCredential.Domain, System.Net.FtpControlStream.FormatFtpCommand(), System.Net.FtpControlStream.GetPathInfo(), System.Net.FtpControlStream.GetPortCommandLine(), System.Net.NetEventSource.Info(), System.Globalization.CultureInfo.InvariantCulture, System.list, System.Net.NetEventSource.Log, System.SR.net_ftp_invalid_uri, System.Net.NetworkCredential.Password, System.text, and System.Net.NetworkCredential.UserName.