Aliyun.Acs.Core.Http.HttpResponse.ReadContent C# (CSharp) Method

ReadContent() public static method

public static ReadContent ( HttpResponse response, HttpWebResponse rsp ) : byte[]
response HttpResponse
rsp System.Net.HttpWebResponse
return byte[]
        public static byte[] ReadContent(HttpResponse response, HttpWebResponse rsp)
        {
            MemoryStream ms = new MemoryStream();
            byte[] buffer = new byte[bufferLength];
            Stream stream = rsp.GetResponseStream();

            while (true)
            {
                int length = stream.Read(buffer, 0, bufferLength);
                if (length == 0)
                {
                    break;
                }
                ms.Write(buffer, 0, length);
            }
            ms.Seek(0, SeekOrigin.Begin);
            byte[] bytes = new byte[ms.Length];
            ms.Read(bytes, 0, bytes.Length);

            ms.Close();
            ms.Dispose();
            stream.Close();
            stream.Dispose();
            return bytes;
        }