Microsoft.Protocols.TestSuites.Common.ChunkedResponse.ReadLine C# (CSharp) Méthode

ReadLine() private static méthode

The method to read one line from the response data.
private static ReadLine ( byte &currentData, bool isKeepReturn ) : byte[]
currentData byte The current data will be processed.
isKeepReturn bool The flag to indicate if to keep the return key in the line.
Résultat byte[]
        private static byte[] ReadLine(ref byte[] currentData, bool isKeepReturn)
        {
            int length = 0;
            byte[] lineBuffer;

            for (int i = 0; i < currentData.Length - 1; i++)
            {
                // To check the Return key in the currentData
                if (currentData[i] == 0x0D && currentData[i + 1] == 0x0A)
                {
                    if (isKeepReturn)
                    {
                        lineBuffer = new byte[length + 2];
                        Array.Copy(currentData, lineBuffer, length + 2);
                    }
                    else
                    {
                        lineBuffer = new byte[length];
                        Array.Copy(currentData, lineBuffer, length);
                    }

                    if (i + 2 < currentData.Length)
                    {
                        byte[] laveData = new byte[currentData.Length - length - 2];
                        Array.Copy(currentData, i + 2, laveData, 0, currentData.Length - length - 2);
                        currentData = laveData;
                    }

                    return lineBuffer;
                }
                else
                {
                    length += 1;
                }
            }

            lineBuffer = new byte[currentData.Length];
            Array.Copy(currentData, lineBuffer, currentData.Length);
            currentData = new byte[0] { };

            return lineBuffer;
        }
    }