HttpToken.cs 990 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using BeetleX.Buffers;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. namespace PlatformBenchmarks
  6. {
  7. public class HttpToken
  8. {
  9. private byte[] mLengthBuffer = new byte[10];
  10. public byte[] Buffer
  11. {
  12. get;
  13. private set;
  14. }
  15. public HttpToken()
  16. {
  17. Buffer = new byte[2048];
  18. }
  19. public byte[] GetLengthBuffer(string length)
  20. {
  21. Encoding.ASCII.GetBytes(length, 0, length.Length, mLengthBuffer, 0);
  22. for (int i = length.Length; i < 10; i++)
  23. {
  24. mLengthBuffer[i] = 32;
  25. }
  26. return mLengthBuffer;
  27. }
  28. public int ContentPostion { get; set; }
  29. public MemoryBlockCollection ContentLength { get; set; }
  30. public void FullLength(string length)
  31. {
  32. var item = GetLengthBuffer(length);
  33. ContentLength.Full(item);
  34. }
  35. }
  36. }