System.Net.FtpWebRequest.EnsureFtpWebResponse C# (CSharp) Метод

EnsureFtpWebResponse() приватный Метод

Creates an FTP WebResponse based off the responseStream and our active Connection

private EnsureFtpWebResponse ( Exception exception ) : void
exception Exception
Результат void
        private void EnsureFtpWebResponse(Exception exception)
        {
            if (_ftpWebResponse == null || (_ftpWebResponse.GetResponseStream() is FtpWebResponse.EmptyStream && _stream != null))
            {
                lock (_syncObject)
                {
                    if (_ftpWebResponse == null || (_ftpWebResponse.GetResponseStream() is FtpWebResponse.EmptyStream && _stream != null))
                    {
                        Stream responseStream = _stream;

                        if (_methodInfo.IsUpload)
                        {
                            responseStream = null;
                        }

                        if (_stream != null && _stream.CanRead && _stream.CanTimeout)
                        {
                            _stream.ReadTimeout = ReadWriteTimeout;
                            _stream.WriteTimeout = ReadWriteTimeout;
                        }

                        FtpControlStream connection = _connection;
                        long contentLength = connection != null ? connection.ContentLength : -1;

                        if (responseStream == null)
                        {
                            // If the last command was SIZE, we set the ContentLength on
                            // the FtpControlStream to be the size of the file returned in the
                            // response. We should propagate that file size to the response so
                            // users can access it. This also maintains the compatibility with
                            // HTTP when returning size instead of content.
                            if (contentLength < 0)
                                contentLength = 0;
                        }

                        if (_ftpWebResponse != null)
                        {
                            _ftpWebResponse.SetResponseStream(responseStream);
                        }
                        else
                        {
                            if (connection != null)
                                _ftpWebResponse = new FtpWebResponse(responseStream, contentLength, connection.ResponseUri, connection.StatusCode, connection.StatusLine, connection.LastModified, connection.BannerMessage, connection.WelcomeMessage, connection.ExitMessage);
                            else
                                _ftpWebResponse = new FtpWebResponse(responseStream, -1, _uri, FtpStatusCode.Undefined, null, DateTime.Now, null, null, null);
                        }
                    }
                }
            }

            if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"Returns {_ftpWebResponse} with stream {_ftpWebResponse._responseStream}");

            return;
        }