Example #1
0
            public void SendResponseData(Stream writerStream)
            {
                if (!_cookies.IsNull())
                {
                    _responseHeader.Add(_cookies.ToResponseData(), null);
                }

                _responseHeader.Add("Connection", "Keep-Alive");
                _responseHeader.Add("\r\n", null);

                var retBytes = Encoding.UTF8.GetBytes(_responseHeader.Aggregate("", (current, header) => current + header.Key + (header.Value != null ? $":{header.Value}" : "") + Environment.NewLine)).ToArray();

                writerStream.Write(retBytes, 0, retBytes.Length);

                while (ContentStream.Position < ContentStream.Length)
                {
                    ContentStream.CopyTo(writerStream, BufferSize);
                    Task.Delay(500);
                }
            }