System.Net.Security.Tests.HttpsTestServer.HttpConversation C# (CSharp) Метод

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

private HttpConversation ( SslStream tls ) : Task
tls SslStream
Результат Task
        private async Task<bool> HttpConversation(SslStream tls)
        {
            int totalBytesRead = 0;
            int chunks = 0;

            SslProtocol = tls.SslProtocol;

            while (totalBytesRead < 5)
            {
                var requestBuffer = new byte[2048];
                int bytesRead = await tls.ReadAsync(requestBuffer, 0, requestBuffer.Length);
                totalBytesRead += bytesRead;

                string requestString = Encoding.UTF8.GetString(requestBuffer, 0, bytesRead);

                _log.WriteLine("[Server] Received {0} bytes: <<<{1}>>>", bytesRead, requestString);
                if (bytesRead == 0)
                {
                    return false;
                }

                if (bytesRead == 1 && chunks == 0)
                {
                    AuxRecordDetected = true;
                }

                chunks++;
            }

            _log.WriteLine("[Server] Using cipher {0}", tls.CipherAlgorithm);

            // Test is inconclusive if any non-CBC cipher is used:
            if (tls.CipherAlgorithm == CipherAlgorithmType.None ||
                tls.CipherAlgorithm == CipherAlgorithmType.Null ||
                tls.CipherAlgorithm == CipherAlgorithmType.Rc4)
            {
                IsAuxRecordDetectionInconclusive = true;
            }

            byte[] responseBuffer = Encoding.UTF8.GetBytes(ResponseString);
            await tls.WriteAsync(responseBuffer, 0, responseBuffer.Length);
            _log.WriteLine("[Server] Replied with {0} bytes.", responseBuffer.Length);
            return true;
        }
    }