{
string AuthenticationType { get; }
bool CanPreAuthenticate { get; }
- System.Net.Authorization Authenticate(string challenge, System.Net.WebRequest request, System.Net.ICredentials credentials);
- System.Net.Authorization PreAuthenticate(System.Net.WebRequest request, System.Net.ICredentials credentials);
+ System.Net.Authorization? Authenticate(string challenge, System.Net.WebRequest request, System.Net.ICredentials credentials);
+ System.Net.Authorization? PreAuthenticate(System.Net.WebRequest request, System.Net.ICredentials credentials);
}
public partial interface ICredentialPolicy
{
//
// FYI: Will do 2 attempts max as per AttemptedRecovery
//
- Stream stream;
+ Stream? stream;
while (true)
{
catch (WebException webException)
{
// If this was a timeout, throw a timeout exception
- IOException? ioEx = webException.InnerException as IOException;
- if (ioEx != null)
+ if (webException.InnerException is IOException ioEx &&
+ ioEx.InnerException is SocketException sEx &&
+ sEx.SocketErrorCode == SocketError.TimedOut)
{
- SocketException? sEx = ioEx.InnerException as SocketException;
- if (sEx != null)
- {
- if (sEx.SocketErrorCode == SocketError.TimedOut)
- {
- SetException(ExceptionDispatchInfo.SetCurrentStackTrace(new WebException(SR.net_timeout, WebExceptionStatus.Timeout)));
- }
- }
+ SetException(ExceptionDispatchInfo.SetCurrentStackTrace(new WebException(SR.net_timeout, WebExceptionStatus.Timeout)));
+ }
+ else
+ {
+ SetException(webException);
}
-
- SetException(webException);
}
catch (Exception exception)
{
private Exception TranslateConnectException(Exception e)
{
- SocketException? se = e as SocketException;
- if (se != null)
+ if (e is SocketException se)
{
if (se.SocketErrorCode == SocketError.HostNotFound)
{
return new FtpControlStream(client);
}
- private Stream TimedSubmitRequestHelper(bool isAsync)
+ private Stream? TimedSubmitRequestHelper(bool isAsync)
{
if (isAsync)
{
}
}
- return stream!;
+ return stream;
}
/// <summary>
try
{
- stream = (FtpDataStream)TimedSubmitRequestHelper(true);
+ stream = (FtpDataStream?)TimedSubmitRequestHelper(true);
}
catch (Exception e)
{
{
public interface IAuthenticationModule
{
- Authorization Authenticate(string challenge, WebRequest request, ICredentials credentials);
- Authorization PreAuthenticate(WebRequest request, ICredentials credentials);
+ Authorization? Authenticate(string challenge, WebRequest request, ICredentials credentials);
+ Authorization? PreAuthenticate(WebRequest request, ICredentials credentials);
bool CanPreAuthenticate { get; }
string AuthenticationType { get; }
}