OpenHome.Git.Fetcher.ReadFetchHeader C# (CSharp) Method

ReadFetchHeader() public static method

public static ReadFetchHeader ( BinaryReader aReader, string &aSha1 ) : byte[]
aReader System.IO.BinaryReader
aSha1 string
return byte[]
        public static byte[] ReadFetchHeader(BinaryReader aReader, out string aSha1)
        {
            byte[] bytes = aReader.ReadBytes(4);

            string length = ASCIIEncoding.ASCII.GetString(bytes);

            int len = int.Parse(length, System.Globalization.NumberStyles.HexNumber);

            if (len == 0)
            {
                aSha1 = null;
                return (null);
            }

            aSha1 = ASCIIEncoding.ASCII.GetString(aReader.ReadBytes(40));

            string space = ASCIIEncoding.ASCII.GetString(aReader.ReadBytes(1));

            if (space != " ")
            {
                throw (new GitException("Communications error"));
            }

            return (aReader.ReadBytes(len - 45));
        }