Chunk.php 987 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * This file is part of workerman.
  4. *
  5. * Licensed under The MIT License
  6. * For full copyright and license information, please see the MIT-LICENSE.txt
  7. * Redistributions of files must retain the above copyright notice.
  8. *
  9. * @author walkor<walkor@workerman.net>
  10. * @copyright walkor<walkor@workerman.net>
  11. * @link http://www.workerman.net/
  12. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  13. */
  14. namespace Workerman\Protocols\Http;
  15. /**
  16. * Class Chunk
  17. * @package Workerman\Protocols\Http
  18. */
  19. class Chunk
  20. {
  21. /**
  22. * Chunk buffer.
  23. *
  24. * @var string
  25. */
  26. protected $_buffer = null;
  27. /**
  28. * Chunk constructor.
  29. * @param string $buffer
  30. */
  31. public function __construct($buffer)
  32. {
  33. $this->_buffer = $buffer;
  34. }
  35. /**
  36. * __toString
  37. *
  38. * @return string
  39. */
  40. public function __toString()
  41. {
  42. return \dechex(\strlen($this->_buffer))."\r\n$this->_buffer\r\n";
  43. }
  44. }