117 if (
string.IsNullOrEmpty(
value))
142 [param: DisallowNull]
149 if (
string.IsNullOrEmpty(
value))
163 [param: DisallowNull]
485 string userName = userInfo;
486 string password =
"";
487 int num = userInfo.IndexOf(
':');
496 if (networkCredential ==
null)
598 return contextAwareResult;
614 contextAwareResult =
null;
622 contextAwareResult =
null;
626 if (contextAwareResult ==
null)
653 return contextAwareResult;
668 if (lazyAsyncResult.EndCalled)
672 lazyAsyncResult.InternalWaitForCompletion();
673 lazyAsyncResult.EndCalled =
true;
756 contextAwareResult =
new ContextAwareResult(captureIdentity:
true, forceCaptureContext:
true,
this,
state, callback);
763 return contextAwareResult;
789 if (lazyAsyncResult.EndCalled)
793 lazyAsyncResult.InternalWaitForCompletion();
794 lazyAsyncResult.EndCalled =
true;
797 lazyAsyncResult.EndCalled =
true;
823 if (ftpControlStream ==
null)
890 if (ex.SocketErrorCode ==
SocketError.HostNotFound)
905 await client.
ConnectAsync(_uri.Host, _uri.Port).ConfigureAwait(continueOnCapturedContext:
false);
910 obj = TranslateConnectException(e);
912 AsyncRequestCallback(
obj);
917 string host = _uri.Host;
918 int port = _uri.Port;
926 throw TranslateConnectException(e);
935 if (_requestCompleteAsyncResult ==
null)
939 return _connection.
SubmitRequest(
this, isAsync:
true, readInitalResponseOnConnect:
true);
946 stream = _connection.
SubmitRequest(
this, isAsync:
false, readInitalResponseOnConnect:
true);
957 if (flag || !timer.
Cancel())
985 if (connection !=
null)
1004 if (_connection ==
null)
1030 if (_exception ==
null)
1041 else if (connection !=
null && connection.
StatusCode != 0)
1050 if (connection !=
null && _ftpWebResponse !=
null)
1059 if (_exception !=
null)
1069 AsyncRequestCallback(
obj);
1073 SyncRequestCallback(
obj);
1082 bool flag =
obj ==
null;
1098 if (connection !=
null)
1100 EnsureFtpWebResponse(
null);
1111 FinishRequestStage(stage);
1124 bool flag =
obj ==
null;
1127 System.
Net.
NetEventSource.
Info(
this, $
"stream:{ftpDataStream} conn:{ftpControlStream} exp:{ex} completedRequest:{flag}",
"AsyncRequestCallback");
1133 if (AttemptedRecovery(ex))
1135 ftpControlStream = CreateConnection();
1136 if (ftpControlStream ==
null)
1148 if (ftpControlStream ==
null)
1163 _connection = ftpControlStream;
1171 ftpDataStream = (
FtpDataStream)TimedSubmitRequestHelper(isAsync:
true);
1179 if (ftpDataStream !=
null)
1188 _stream = ftpDataStream;
1191 EnsureFtpWebResponse(
null);
1192 stage = (ftpDataStream.CanRead ? RequestStage.ReadReady :
RequestStage.WriteReady);
1200 ftpControlStream = _connection;
1201 if (ftpControlStream !=
null)
1203 EnsureFtpWebResponse(
null);
1215 FinishRequestStage(stage);
1225 if (_exception !=
null)
1235 requestStage = _requestStage;
1238 return requestStage;
1244 if (stage > requestStage)
1246 _requestStage = stage;
1250 return requestStage;
1252 writeAsyncResult = _writeAsyncResult;
1253 readAsyncResult = _readAsyncResult;
1254 connection = _connection;
1259 return requestStage;
1266 if ((stage ==
RequestStage.ReleaseConnection || requestStage ==
RequestStage.ReleaseConnection) && connection !=
null)
1270 if (_exception !=
null)
1272 connection.
Abort(_exception);
1282 if (_async && _requestCompleteAsyncResult !=
null)
1288 return requestStage;
1296 if (_methodInfo.
IsUpload && !_getRequestStreamStarted)
1298 if (_stream !=
null)
1337 connection = _connection;
1371 _stream.ReadTimeout = ReadWriteTimeout;
1372 _stream.WriteTimeout = ReadWriteTimeout;
1376 if (
stream ==
null && num < 0)
1380 if (_ftpWebResponse !=
null)
1384 else if (connection !=
null)
1397 System.
Net.
NetEventSource.
Info(
this, $
"Returns {_ftpWebResponse} with stream {_ftpWebResponse._responseStream}",
"EnsureFtpWebResponse");
1407 if (_connection !=
null)
Exception? InnerException
Stream SubmitRequest(WebRequest request, bool isAsync, bool readInitalResponseOnConnect)
virtual void Abort(Exception e)
void CheckContinuePipeline()
bool FinishPostingAsyncOp()
object StartPostingAsyncOp()
static NetworkCredential DefaultNetworkCredentials
static WebException RequestAbortedException
static NotSupportedException PropertyNotSupportedException
static WebException TimeoutException
void SetSocketTimeoutOption(int timeout)
static FtpMethodInfo GetMethodInfo(string method)
FtpControlStream CreateConnection()
bool _getRequestStreamStarted
async void CreateConnectionAsync()
readonly TimerThread.Callback _timerCallback
override IAsyncResult BeginGetResponse(AsyncCallback? callback, object? state)
override? RequestCachePolicy CachePolicy
bool AttemptedRecovery(Exception e)
LazyAsyncResult _readAsyncResult
static readonly TimerThread.Queue s_DefaultTimerQueue
FtpControlStream _connection
override bool UseDefaultCredentials
override WebResponse GetResponse()
void RequestCallback(object obj)
override bool PreAuthenticate
WebHeaderCollection _ftpRequestHeaders
TimerThread.Queue _timerQueue
FtpWebResponse _ftpWebResponse
void DataStreamClosed(CloseExState closeState)
override Stream EndGetRequestStream(IAsyncResult asyncResult)
string _connectionGroupName
override IAsyncResult BeginGetRequestStream(AsyncCallback? callback, object? state)
void SubmitRequest(bool isAsync)
void EnsureFtpWebResponse(Exception exception)
override? ICredentials Credentials
override? IWebProxy Proxy
RequestStage _requestStage
override WebResponse EndGetResponse(IAsyncResult asyncResult)
RequestStage FinishRequestStage(RequestStage stage)
ContextAwareResult _writeAsyncResult
ServicePoint _servicePoint
Stream TimedSubmitRequestHelper(bool isAsync)
override? string ContentType
FtpMethodInfo _methodInfo
void TimerCallback(TimerThread.Timer timer, int timeNoticed, object context)
Exception TranslateConnectException(Exception e)
void SetException(Exception exception)
override Stream GetRequestStream()
static readonly NetworkCredential s_defaultFtpNetworkCredential
X509CertificateCollection ClientCertificates
X509CertificateCollection _clientCertificates
static new? RequestCachePolicy DefaultCachePolicy
void AsyncRequestCallback(object obj)
override? string ConnectionGroupName
LazyAsyncResult _requestCompleteAsyncResult
override long ContentLength
void SyncRequestCallback(object obj)
void UpdateStatus(FtpStatusCode statusCode, string statusLine, string exitMessage)
override Stream GetResponseStream()
void SetResponseStream(Stream stream)
object InternalWaitForCompletion()
bool InternalPeekCompleted
void InvokeCallback(object result)
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
static void Error(object thisOrContextObject, FormattableString formattableString, [CallerMemberName] string memberName=null)
static void Associate(object first, object second, [CallerMemberName] string memberName=null)
void SetSocketTimeoutOption(int timeout)
static ServicePoint FindServicePoint(Uri address)
Task ConnectAsync(IPAddress address, int port)
void Connect(string hostname, int port)
static Queue GetOrCreateQueue(int durationMilliseconds)
static ? RequestCachePolicy DefaultCachePolicy
static Exception SetCurrentStackTrace(Exception source)
static string net_ftp_invalid_renameto
static string net_ftp_no_defaultcreds
static string net_reqsubmitted
static string net_io_invalidendcall
static string net_ftp_invalid_method_name
static string Format(string resourceFormat, object p1)
static string net_ftp_servererror
static string net_webstatus_NameResolutionFailure
static string net_io_timeout_use_gt_zero
static string net_nouploadonget
static string net_timeout
static string net_io_timeout_use_ge_zero
static string net_io_invalidasyncresult
static string net_repcall
static string net_webstatus_ConnectFailure
static string net_ftp_unsupported_method
static readonly string UriSchemeFtp
static string UnescapeDataString(string stringToUnescape)
static unsafe DateTime UtcNow