Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
FtpControlStream.cs
Go to the documentation of this file.
3using System.IO;
5using System.Text;
6
7namespace System.Net;
8
9internal sealed class FtpControlStream : CommandStream
10{
11 private enum GetPathOption
12 {
13 Normal,
16 }
17
19
21
23
25
27
29
31
32 private string _currentTypeSetting = string.Empty;
33
34 private long _contentLength = -1L;
35
37
39
40 private string _loginDirectory;
41
43
45
47
49
51
52 internal string StatusLine;
53
54 private static readonly AsyncCallback s_acceptCallbackDelegate = AcceptCallback;
55
56 private static readonly AsyncCallback s_connectCallbackDelegate = ConnectCallback;
57
58 private static readonly AsyncCallback s_SSLHandshakeCallback = SSLHandshakeCallback;
59
61 {
62 get
63 {
64 if (_credentials != null && _credentials.IsAlive)
65 {
67 }
68 return null;
69 }
70 set
71 {
72 if (_credentials == null)
73 {
74 _credentials = new WeakReference(null);
75 }
76 _credentials.Target = value;
77 }
78 }
79
80 internal long ContentLength => _contentLength;
81
83
85
86 internal string BannerMessage
87 {
88 get
89 {
90 if (_bannerMessage == null)
91 {
92 return null;
93 }
94 return _bannerMessage.ToString();
95 }
96 }
97
98 internal string WelcomeMessage
99 {
100 get
101 {
102 if (_welcomeMessage == null)
103 {
104 return null;
105 }
106 return _welcomeMessage.ToString();
107 }
108 }
109
110 internal string ExitMessage
111 {
112 get
113 {
114 if (_exitMessage == null)
115 {
116 return null;
117 }
118 return _exitMessage.ToString();
119 }
120 }
121
123 : base(client)
124 {
125 }
126
127 internal void AbortConnect()
128 {
130 if (dataSocket != null)
131 {
132 try
133 {
134 dataSocket.Close();
135 }
137 {
138 }
139 }
140 }
141
143 {
145 Socket dataSocket = ftpControlStream._dataSocket;
146 try
147 {
148 ftpControlStream._dataSocket = dataSocket.EndAccept(asyncResult);
149 if (!ftpControlStream.ServerAddress.Equals(((IPEndPoint)ftpControlStream._dataSocket.RemoteEndPoint).Address))
150 {
151 ftpControlStream._dataSocket.Close();
153 }
154 ftpControlStream.ContinueCommandPipeline();
155 }
156 catch (Exception obj)
157 {
158 ftpControlStream.CloseSocket();
159 ftpControlStream.InvokeRequestCallback(obj);
160 }
161 finally
162 {
163 dataSocket.Close();
164 }
165 }
166
168 {
170 try
171 {
172 ftpControlStream._dataSocket.EndConnect(asyncResult);
173 ftpControlStream.ContinueCommandPipeline();
174 }
175 catch (Exception obj)
176 {
177 ftpControlStream.CloseSocket();
178 ftpControlStream.InvokeRequestCallback(obj);
179 }
180 }
181
183 {
185 try
186 {
187 ftpControlStream._tlsStream.EndAuthenticateAsClient(asyncResult);
188 ftpControlStream.ContinueCommandPipeline();
189 }
190 catch (Exception obj)
191 {
192 ftpControlStream.CloseSocket();
193 ftpControlStream.InvokeRequestCallback(obj);
194 }
195 }
196
198 {
199 if (_dataSocket == null)
200 {
201 throw new System.Net.InternalException();
202 }
203 if (_tlsStream != null)
204 {
206 _tlsStream = null;
207 return PipelineInstruction.GiveStream;
208 }
210 if (base.UsingSecureStream)
211 {
213 TlsStream tlsStream = new TlsStream(networkStream, _dataSocket, ftpWebRequest.RequestUri.Host, ftpWebRequest.ClientCertificates);
215 if (_isAsync)
216 {
218 tlsStream.BeginAuthenticateAsClient(s_SSLHandshakeCallback, this);
219 return PipelineInstruction.Pause;
220 }
221 tlsStream.AuthenticateAsClient();
222 }
224 return PipelineInstruction.GiveStream;
225 }
226
227 protected override void ClearState()
228 {
229 _contentLength = -1L;
231 _responseUri = null;
232 _dataHandshakeStarted = false;
233 StatusCode = FtpStatusCode.Undefined;
234 StatusLine = null;
235 _dataSocket = null;
236 _passiveEndPoint = null;
237 _tlsStream = null;
238 base.ClearState();
239 }
240
242 {
243 if (System.Net.NetEventSource.Log.IsEnabled())
244 {
245 System.Net.NetEventSource.Info(this, $"Command:{entry?.Command} Description:{response?.StatusDescription}", "PipelineCallback");
246 }
247 if (response == null)
248 {
249 return PipelineInstruction.Abort;
250 }
251 FtpStatusCode status = (FtpStatusCode)response.Status;
252 if (status != FtpStatusCode.ClosingControl)
253 {
254 StatusCode = status;
255 StatusLine = response.StatusDescription;
256 }
257 if (response.InvalidStatusCode)
258 {
260 }
261 if (_index == -1)
262 {
263 switch (status)
264 {
265 case FtpStatusCode.SendUserCommand:
268 return PipelineInstruction.Advance;
269 case FtpStatusCode.ServiceTemporarilyNotAvailable:
270 return PipelineInstruction.Reread;
271 default:
272 throw GenerateException(status, response.StatusDescription, null);
273 }
274 }
275 if (entry.Command == "OPTS utf8 on\r\n")
276 {
277 if (response.PositiveCompletion)
278 {
279 base.Encoding = Encoding.UTF8;
280 }
281 else
282 {
283 base.Encoding = Encoding.Default;
284 }
285 return PipelineInstruction.Advance;
286 }
287 if (entry.Command.IndexOf("USER", StringComparison.Ordinal) != -1 && status == FtpStatusCode.LoggedInProceed)
288 {
289 _loginState = FtpLoginState.LoggedIn;
290 _index++;
291 }
292 if (response.TransientFailure || response.PermanentFailure)
293 {
294 if (status == FtpStatusCode.ServiceNotAvailable)
295 {
297 }
298 throw GenerateException(status, response.StatusDescription, null);
299 }
300 if (_loginState != FtpLoginState.LoggedIn && entry.Command.IndexOf("PASS", StringComparison.Ordinal) != -1)
301 {
302 if (status != FtpStatusCode.NeedLoginAccount && status != FtpStatusCode.LoggedInProceed)
303 {
304 throw GenerateException(status, response.StatusDescription, null);
305 }
306 _loginState = FtpLoginState.LoggedIn;
307 }
308 if (entry.HasFlag(PipelineEntryFlags.CreateDataConnection) && (response.PositiveCompletion || response.PositiveIntermediate))
309 {
310 bool isSocketReady;
312 if (!isSocketReady)
313 {
314 return result;
315 }
316 }
317 switch (status)
318 {
319 case FtpStatusCode.DataAlreadyOpen:
320 case FtpStatusCode.OpeningData:
321 {
322 if (_dataSocket == null)
323 {
324 return PipelineInstruction.Abort;
325 }
326 if (!entry.HasFlag(PipelineEntryFlags.GiveDataStream))
327 {
329 return PipelineInstruction.Abort;
330 }
331 TryUpdateContentLength(response.StatusDescription);
333 if (ftpWebRequest.MethodInfo.ShouldParseForResponseUri)
334 {
335 TryUpdateResponseUri(response.StatusDescription, ftpWebRequest);
336 }
338 }
339 case FtpStatusCode.LoggedInProceed:
341 break;
342 case FtpStatusCode.ClosingControl:
343 _exitMessage.Append(response.StatusDescription);
344 CloseSocket();
345 break;
346 case FtpStatusCode.ServerWantsSecureSession:
347 {
348 if (base.NetworkStream is TlsStream)
349 {
350 break;
351 }
353 TlsStream tlsStream = new TlsStream(base.NetworkStream, base.Socket, ftpWebRequest2.RequestUri.Host, ftpWebRequest2.ClientCertificates);
354 if (_isAsync)
355 {
356 tlsStream.BeginAuthenticateAsClient(delegate(IAsyncResult ar)
357 {
358 try
359 {
360 tlsStream.EndAuthenticateAsClient(ar);
361 base.NetworkStream = tlsStream;
363 }
364 catch (Exception obj)
365 {
366 CloseSocket();
368 }
369 }, null);
370 return PipelineInstruction.Pause;
371 }
372 tlsStream.AuthenticateAsClient();
373 base.NetworkStream = tlsStream;
374 break;
375 }
376 case FtpStatusCode.FileStatus:
377 if (entry.Command.StartsWith("SIZE ", StringComparison.Ordinal))
378 {
380 }
381 else if (entry.Command.StartsWith("MDTM ", StringComparison.Ordinal))
382 {
384 }
385 break;
386 case FtpStatusCode.PathnameCreated:
387 if (entry.Command == "PWD\r\n" && !entry.HasFlag(PipelineEntryFlags.UserCommand))
388 {
389 _loginDirectory = GetLoginDirectory(response.StatusDescription);
390 }
391 break;
392 default:
393 if (entry.Command.IndexOf("CWD", StringComparison.Ordinal) != -1)
394 {
396 }
397 break;
398 }
399 if (response.PositiveIntermediate || (!base.UsingSecureStream && entry.Command == "AUTH TLS\r\n"))
400 {
401 return PipelineInstruction.Reread;
402 }
403 return PipelineInstruction.Advance;
404 }
405
407 {
408 bool flag = false;
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 }
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 {
477 }
479 {
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 {
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 }
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 + "/"));
525 string parameter = ((string.IsNullOrEmpty(ftpWebRequest.RenameTo) || !ftpWebRequest.RenameTo.StartsWith("/", StringComparison.OrdinalIgnoreCase)) ? (text4 + ftpWebRequest.RenameTo) : ftpWebRequest.RenameTo);
527 }
528 else if (ftpWebRequest.MethodInfo.HasFlag(FtpMethodFlags.DoesNotTakeParameter))
529 {
531 }
532 else if (ftpWebRequest.MethodInfo.HasFlag(FtpMethodFlags.MustChangeWorkingDirectoryToPath))
533 {
535 }
536 else
537 {
539 }
540 list.Add(new PipelineEntry(FormatFtpCommand("QUIT", null)));
541 return list.ToArray();
542 }
543
545 {
546 isSocketReady = false;
548 {
549 isSocketReady = true;
550 return PipelineInstruction.Pause;
551 }
553 bool flag = false;
554 int port = -1;
555 if (entry.Command == "PASV\r\n" || entry.Command == "EPSV\r\n")
556 {
557 if (!response.PositiveCompletion)
558 {
560 return PipelineInstruction.Abort;
561 }
562 port = ((!(entry.Command == "PASV\r\n")) ? GetPortV6(response.StatusDescription) : GetPortV4(response.StatusDescription));
563 flag = true;
564 }
565 if (flag)
566 {
567 try
568 {
570 }
572 {
574 }
575 IPEndPoint localEP = new IPEndPoint(((IPEndPoint)base.Socket.LocalEndPoint).Address, 0);
577 _passiveEndPoint = new IPEndPoint(base.ServerAddress, port);
578 }
579 if (_passiveEndPoint != null)
580 {
582 _passiveEndPoint = null;
583 if (System.Net.NetEventSource.Log.IsEnabled())
584 {
585 System.Net.NetEventSource.Info(this, "starting Connect()", "QueueOrCreateDataConection");
586 }
587 if (_isAsync)
588 {
590 return PipelineInstruction.Pause;
591 }
593 return PipelineInstruction.Advance;
594 }
595 if (System.Net.NetEventSource.Log.IsEnabled())
596 {
597 System.Net.NetEventSource.Info(this, "starting Accept()", "QueueOrCreateDataConection");
598 }
599 if (_isAsync)
600 {
602 return PipelineInstruction.Pause;
603 }
605 try
606 {
608 if (!base.ServerAddress.Equals(((IPEndPoint)_dataSocket.RemoteEndPoint).Address))
609 {
612 }
613 isSocketReady = true;
614 return PipelineInstruction.Pause;
615 }
616 finally
617 {
618 dataSocket.Close();
619 }
620 }
621
622 private static void GetPathInfo(GetPathOption pathOption, Uri uri, out string path, out string directory, out string filename)
623 {
624 path = uri.GetComponents(UriComponents.Path, UriFormat.Unescaped);
625 int num = path.LastIndexOf('/');
626 if (pathOption == GetPathOption.AssumeFilename && num != -1 && num == path.Length - 1)
627 {
628 path = path.Substring(0, path.Length - 1);
629 num = path.LastIndexOf('/');
630 }
631 if (pathOption == GetPathOption.AssumeNoFilename)
632 {
633 directory = path;
634 filename = string.Empty;
635 }
636 else
637 {
638 directory = path.Substring(0, num + 1);
639 filename = path.Substring(num + 1, path.Length - (num + 1));
640 }
641 if (directory.Length > 1 && directory[directory.Length - 1] == '/')
642 {
643 directory = directory.Substring(0, directory.Length - 1);
644 }
645 }
646
647 private string FormatAddress(IPAddress address, int Port)
648 {
649 byte[] addressBytes = address.GetAddressBytes();
651 for (int i = (address.IsIPv4MappedToIPv6 ? 12 : 0); i < addressBytes.Length; i++)
652 {
653 stringBuilder.Append(addressBytes[i]);
654 stringBuilder.Append(',');
655 }
656 stringBuilder.Append(Port / 256);
657 stringBuilder.Append(',');
658 stringBuilder.Append(Port % 256);
659 return stringBuilder.ToString();
660 }
661
662 private string FormatAddressV6(IPAddress address, int port)
663 {
664 return "|2|" + address.ToString() + "|" + port.ToString(NumberFormatInfo.InvariantInfo) + "|";
665 }
666
668 {
669 string[] array = responseString.Split(' ');
670 if (array.Length < 2)
671 {
673 }
675 }
676
678 {
679 DateTime result = _lastModified;
680 string[] array = str.Split(' ', '.');
681 if (array.Length < 2)
682 {
683 return result;
684 }
685 string text = array[1];
686 if (text.Length < 14)
687 {
688 return result;
689 }
690 int year = Convert.ToInt32(text.Substring(0, 4), NumberFormatInfo.InvariantInfo);
691 int month = Convert.ToInt16(text.Substring(4, 2), NumberFormatInfo.InvariantInfo);
692 int day = Convert.ToInt16(text.Substring(6, 2), NumberFormatInfo.InvariantInfo);
693 int hour = Convert.ToInt16(text.Substring(8, 2), NumberFormatInfo.InvariantInfo);
694 int minute = Convert.ToInt16(text.Substring(10, 2), NumberFormatInfo.InvariantInfo);
695 int second = Convert.ToInt16(text.Substring(12, 2), NumberFormatInfo.InvariantInfo);
696 int millisecond = 0;
697 if (array.Length > 2)
698 {
700 }
701 try
702 {
703 result = new DateTime(year, month, day, hour, minute, second, millisecond);
704 result = result.ToLocalTime();
705 }
707 {
708 }
709 catch (ArgumentException)
710 {
711 }
712 return result;
713 }
714
716 {
717 Uri uri = request.RequestUri;
718 int num = str.IndexOf("for ", StringComparison.Ordinal);
719 if (num == -1)
720 {
721 return;
722 }
723 num += 4;
724 int num2 = str.LastIndexOf('(');
725 if (num2 == -1)
726 {
727 num2 = str.Length;
728 }
729 if (num2 > num)
730 {
731 string text = str.Substring(num, num2 - num);
732 text = text.TrimEnd(' ', '.', '\r', '\n');
733 string text2 = text.Replace("%", "%25");
734 text2 = text2.Replace("#", "%23");
735 string absolutePath = uri.AbsolutePath;
736 if (absolutePath.Length > 0 && absolutePath[absolutePath.Length - 1] != '/')
737 {
739 uriBuilder.Path = absolutePath + "/";
740 uri = uriBuilder.Uri;
741 }
742 if (!Uri.TryCreate(uri, text2, out Uri result))
743 {
745 }
746 if (!uri.IsBaseOf(result) || uri.Segments.Length != result.Segments.Length - 1)
747 {
749 }
750 _responseUri = result;
751 }
752 }
753
754 private void TryUpdateContentLength(string str)
755 {
756 int num = str.LastIndexOf('(');
757 if (num == -1)
758 {
759 return;
760 }
761 int num2 = str.IndexOf(" bytes).", StringComparison.Ordinal);
762 if (num2 != -1 && num2 > num)
763 {
764 num++;
765 if (long.TryParse(str.AsSpan(num, num2 - num), NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo, out var result))
766 {
767 _contentLength = result;
768 }
769 }
770 }
771
772 private string GetLoginDirectory(string str)
773 {
774 int num = str.IndexOf('"');
775 int num2 = str.LastIndexOf('"');
776 if (num != -1 && num2 != -1 && num != num2)
777 {
778 return str.Substring(num + 1, num2 - num - 1);
779 }
780 return string.Empty;
781 }
782
783 private int GetPortV4(string responseString)
784 {
785 string[] array = responseString.Split(' ', '(', ',', ')');
786 if (array.Length <= 7)
787 {
789 }
790 int num = array.Length - 1;
791 if (!char.IsNumber(array[num], 0))
792 {
793 num--;
794 }
796 return num2 | (Convert.ToByte(array[num--], NumberFormatInfo.InvariantInfo) << 8);
797 }
798
799 private int GetPortV6(string responseString)
800 {
801 int num = responseString.LastIndexOf('(');
802 int num2 = responseString.LastIndexOf(')');
803 if (num == -1 || num2 <= num)
804 {
806 }
807 string text = responseString.Substring(num + 1, num2 - num - 1);
808 string[] array = text.Split('|');
809 if (array.Length < 4)
810 {
812 }
814 }
815
817 {
818 IPEndPoint localEP = new IPEndPoint(((IPEndPoint)base.Socket.LocalEndPoint).Address, 0);
819 try
820 {
822 }
824 {
826 }
829 }
830
832 {
833 try
834 {
836 if (base.ServerAddress.AddressFamily == AddressFamily.InterNetwork || base.ServerAddress.IsIPv4MappedToIPv6)
837 {
838 return FormatAddress(iPEndPoint.Address, iPEndPoint.Port);
839 }
840 if (base.ServerAddress.AddressFamily == AddressFamily.InterNetworkV6)
841 {
842 return FormatAddressV6(iPEndPoint.Address, iPEndPoint.Port);
843 }
844 throw new System.Net.InternalException();
845 }
847 {
849 }
850 }
851
852 private string FormatFtpCommand(string command, string parameter)
853 {
854 if (!string.IsNullOrEmpty(parameter))
855 {
856 return command + " " + parameter + "\r\n";
857 }
858 return command + "\r\n";
859 }
860
862 {
863 Socket socket = new Socket(templateSocket.AddressFamily, templateSocket.SocketType, templateSocket.ProtocolType);
864 if (templateSocket.AddressFamily == AddressFamily.InterNetworkV6 && templateSocket.DualMode)
865 {
866 socket.DualMode = true;
867 }
868 return socket;
869 }
870
872 {
873 if (System.Net.NetEventSource.Log.IsEnabled())
874 {
875 System.Net.NetEventSource.Info(this, $"CheckValid({response.StatusBuffer})", "CheckValid");
876 }
877 if (response.StatusBuffer.Length < 4)
878 {
879 return true;
880 }
881 string text = response.StatusBuffer.ToString();
882 if (response.Status == -1)
883 {
884 if (!char.IsDigit(text[0]) || !char.IsDigit(text[1]) || !char.IsDigit(text[2]) || (text[3] != ' ' && text[3] != '-'))
885 {
886 return false;
887 }
888 response.StatusCodeString = text.Substring(0, 3);
889 response.Status = Convert.ToInt16(response.StatusCodeString, NumberFormatInfo.InvariantInfo);
890 if (text[3] == '-')
891 {
892 response.Multiline = true;
893 }
894 }
895 int num = 0;
896 while ((num = text.IndexOf("\r\n", validThrough, StringComparison.Ordinal)) != -1)
897 {
898 int num2 = validThrough;
899 validThrough = num + 2;
900 if (!response.Multiline)
901 {
903 return true;
904 }
905 if (text.Length > num2 + 4 && text.Substring(num2, 3) == response.StatusCodeString && text[num2 + 3] == ' ')
906 {
908 return true;
909 }
910 }
911 return true;
912 }
913
915 {
917 {
918 if (ftpWebRequest.MethodInfo.IsUpload)
919 {
920 return TriState.True;
921 }
922 if (ftpWebRequest.MethodInfo.IsDownload)
923 {
924 return TriState.False;
925 }
926 }
927 return TriState.Unspecified;
928 }
929}
void Add(TKey key, TValue value)
static long ToInt64(object? value)
Definition Convert.cs:1623
static int ToInt32(object? value)
Definition Convert.cs:1320
static short ToInt16(object? value)
Definition Convert.cs:1038
static byte ToByte(object? value)
Definition Convert.cs:900
static CultureInfo InvariantCulture
void InvokeRequestCallback(object obj)
Exception GenerateException(string message, WebExceptionStatus status, Exception innerException)
static WebException RequestAbortedException
static readonly AsyncCallback s_connectCallbackDelegate
static void ConnectCallback(IAsyncResult asyncResult)
override bool CheckValid(ResponseDescription response, ref int validThrough, ref int completeLength)
static void AcceptCallback(IAsyncResult asyncResult)
FtpControlStream(TcpClient client)
DateTime GetLastModifiedFrom213Response(string str)
string FormatAddressV6(IPAddress address, int port)
static readonly AsyncCallback s_acceptCallbackDelegate
static void SSLHandshakeCallback(IAsyncResult asyncResult)
static readonly AsyncCallback s_SSLHandshakeCallback
long GetContentLengthFrom213Response(string responseString)
void TryUpdateContentLength(string str)
string GetPortCommandLine(FtpWebRequest request)
override PipelineEntry[] BuildCommandsList(WebRequest req)
int GetPortV6(string responseString)
void TryUpdateResponseUri(string str, FtpWebRequest request)
int GetPortV4(string responseString)
void CreateFtpListenerSocket(FtpWebRequest request)
PipelineInstruction QueueOrCreateFtpDataStream(ref Stream stream)
string GetLoginDirectory(string str)
override PipelineInstruction PipelineCallback(PipelineEntry entry, ResponseDescription response, bool timeout, ref Stream stream)
string FormatAddress(IPAddress address, int Port)
static void GetPathInfo(GetPathOption pathOption, Uri uri, out string path, out string directory, out string filename)
string FormatFtpCommand(string command, string parameter)
Socket CreateFtpDataSocket(FtpWebRequest request, Socket templateSocket)
PipelineInstruction QueueOrCreateDataConection(PipelineEntry entry, ResponseDescription response, bool timeout, ref Stream stream, out bool isSocketReady)
byte[] GetAddressBytes()
Definition IPAddress.cs:377
override string ToString()
Definition IPAddress.cs:390
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
IAsyncResult BeginConnect(EndPoint remoteEP, AsyncCallback? callback, object? state)
Definition Socket.cs:2378
unsafe? EndPoint LocalEndPoint
Definition Socket.cs:615
void Bind(EndPoint localEP)
Definition Socket.cs:1172
void Connect(EndPoint remoteEP)
Definition Socket.cs:1206
IAsyncResult BeginAccept(AsyncCallback? callback, object? state)
Definition Socket.cs:2685
static string net_InvalidStatusCode
Definition SR.cs:78
static string net_ftp_protocolerror
Definition SR.cs:104
static string net_ftp_response_invalid_format
Definition SR.cs:98
static string net_ftp_invalid_status_response
Definition SR.cs:92
static string net_ftp_invalid_uri
Definition SR.cs:94
static string net_ftp_active_address_different
Definition SR.cs:84
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string net_ftp_invalid_response_filename
Definition SR.cs:90
static string net_ftp_server_failed_passive
Definition SR.cs:100
Definition SR.cs:7
static Encoding UTF8
Definition Encoding.cs:526
static Encoding Default
Definition Encoding.cs:345
override string ToString()
StringBuilder Append(char value, int repeatCount)
string[] Segments
Definition Uri.cs:400
static bool TryCreate([NotNullWhen(true)] string? uriString, UriKind uriKind, [NotNullWhen(true)] out Uri? result)
Definition Uri.cs:3793
string AbsolutePath
Definition Uri.cs:239
string GetComponents(UriComponents components, UriFormat format)
Definition Uri.cs:3883
bool IsBaseOf(Uri uri)
Definition Uri.cs:4278
virtual ? object Target
UriFormat
Definition UriFormat.cs:4
static readonly DateTime MinValue
Definition DateTime.cs:35
DateTime ToLocalTime()
Definition DateTime.cs:1068