ByteQueueOutputStream.cs 915 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO;
  5. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Tls
  6. {
  7. /// <summary>OutputStream based on a ByteQueue implementation.</summary>
  8. public sealed class ByteQueueOutputStream
  9. : BaseOutputStream
  10. {
  11. private readonly ByteQueue m_buffer;
  12. public ByteQueueOutputStream()
  13. {
  14. this.m_buffer = new ByteQueue();
  15. }
  16. public ByteQueue Buffer
  17. {
  18. get { return m_buffer; }
  19. }
  20. public override void WriteByte(byte b)
  21. {
  22. m_buffer.AddData(new byte[]{ b }, 0, 1);
  23. }
  24. public override void Write(byte[] buf, int off, int len)
  25. {
  26. m_buffer.AddData(buf, off, len);
  27. }
  28. }
  29. }
  30. #pragma warning restore
  31. #endif