namespace System.Net
{
- internal enum FtpPrimitive
- {
- Upload = 0,
- Download = 1,
- CommandOnly = 2
- };
-
internal enum FtpLoginState : byte
{
NotLoggedIn,
// OR set us up for SSL/TLS, after this we'll be writing securely
else if (status == FtpStatusCode.ServerWantsSecureSession)
{
- // If NetworkStream is a TlsStream, then this must be in the async callback
+ // If NetworkStream is a TlsStream, then this must be in the async callback
// from completing the SSL handshake.
// So just let the pipeline continue.
if (!(NetworkStream is TlsStream))
return result;
}
- //
- // A door into protected CloseSocket() method
- //
- internal void Quit()
- {
- CloseSocket();
- }
-
private enum GetPathOption
{
Normal,
get { return (Flags & FtpMethodFlags.IsDownload) != 0; }
}
- internal bool HasHttpCommand
- {
- get { return (Flags & FtpMethodFlags.HasHttpCommand) != 0; }
- }
-
/// <summary>
/// <para>True if we should attempt to get a response uri
/// out of a server response</para>
}
}
- // Used by FtpControlStream
- internal static NetworkCredential DefaultNetworkCredential
- {
- get
- {
- return s_defaultFtpNetworkCredential;
- }
- }
-
public static new RequestCachePolicy DefaultCachePolicy
{
get
if (stage >= RequestStage.WriteReady)
{
// If writeResult == null and this is an upload request, it means
- // that the user has called GetResponse() without calling
- // GetRequestStream() first. So they are not interested in a
- // stream. Therefore we close the stream so that the
+ // that the user has called GetResponse() without calling
+ // GetRequestStream() first. So they are not interested in a
+ // stream. Therefore we close the stream so that the
// request/pipeline can continue
if (_methodInfo.IsUpload && !_getRequestStreamStarted)
{
return;
}
- /// <summary>
- /// <para>Returns username string</para>
- /// </summary>
- internal string GetUserString()
- {
- string name = null;
- if (this.Credentials != null)
- {
- NetworkCredential networkCreds = this.Credentials.GetCredential(_uri, "basic");
- if (networkCreds != null)
- {
- name = networkCreds.UserName;
- string domain = networkCreds.Domain;
- if (!string.IsNullOrEmpty(domain))
- {
- name = domain + "\\" + name;
- }
- }
- }
- return name == null ? null : (String.Compare(name, "anonymous", StringComparison.InvariantCultureIgnoreCase) == 0 ? null : name);
- }
-
internal void DataStreamClosed(CloseExState closeState)
{
if ((closeState & CloseExState.Abort) == 0)
}
}
- internal void SetContentLength(long value)
- {
- _contentLength = value;
- }
-
public override WebHeaderCollection Headers
{
get
internal int Duration => _durationMilliseconds;
/// <summary>
- /// <para>Creates and returns a handle to a new polled timer.</para>
- /// </summary>
- internal Timer CreateTimer() => CreateTimer(null, null);
-
- /// <summary>
/// <para>Creates and returns a handle to a new timer with attached context.</para>
/// </summary>
internal abstract Timer CreateTimer(Callback callback, object context);
}
/// <summary>
- /// <para>The duration in milliseconds of timer.</para>
- /// </summary>
- internal int Duration => _durationMilliseconds;
-
- /// <summary>
/// <para>The time (relative to Environment.TickCount) when the timer started.</para>
/// </summary>
internal int StartTime => _startTimeMilliseconds;
internal int Expiration => unchecked(_startTimeMilliseconds + _durationMilliseconds);
/// <summary>
- /// <para>The amount of time left on the timer. 0 means it has fired. 1 means it has expired but
- /// not yet fired. -1 means infinite. Int32.MaxValue is the ceiling - the actual value could be longer.</para>
- /// </summary>
- internal int TimeRemaining
- {
- get
- {
- if (HasExpired)
- {
- return 0;
- }
-
- if (Duration == Timeout.Infinite)
- {
- return Timeout.Infinite;
- }
-
- int now = Environment.TickCount;
- int remaining = IsTickBetween(StartTime, Expiration, now) ?
- (int)(Math.Min((uint)unchecked(Expiration - now), (uint)Int32.MaxValue)) : 0;
- return remaining < 2 ? remaining + 1 : remaining;
- }
- }
-
- /// <summary>
/// <para>Cancels the timer. Returns true if the timer hasn't and won't fire; false if it has or will.</para>
/// </summary>
internal abstract bool Cancel();
if (NetEventSource.IsEnabled) NetEventSource.Info(null, $"Awoke, cause {(waitResult == WaitHandle.WaitTimeout ? "Timeout" : "Prod")}");
- // If we timed out with nothing to do, shut down.
+ // If we timed out with nothing to do, shut down.
if (waitResult == WaitHandle.WaitTimeout && !haveNextTick)
{
Interlocked.CompareExchange(ref s_threadState, (int)TimerThreadState.Idle, (int)TimerThreadState.Running);