Ei kuvausta

ChunkInterface.php 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Contracts\HttpClient;
  11. use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
  12. /**
  13. * The interface of chunks returned by ResponseStreamInterface::current().
  14. *
  15. * When the chunk is first, last or timeout, the content MUST be empty.
  16. * When an unchecked timeout or a network error occurs, a TransportExceptionInterface
  17. * MUST be thrown by the destructor unless one was already thrown by another method.
  18. *
  19. * @author Nicolas Grekas <p@tchwork.com>
  20. */
  21. interface ChunkInterface
  22. {
  23. /**
  24. * Tells when the idle timeout has been reached.
  25. *
  26. * @throws TransportExceptionInterface on a network error
  27. */
  28. public function isTimeout(): bool;
  29. /**
  30. * Tells when headers just arrived.
  31. *
  32. * @throws TransportExceptionInterface on a network error or when the idle timeout is reached
  33. */
  34. public function isFirst(): bool;
  35. /**
  36. * Tells when the body just completed.
  37. *
  38. * @throws TransportExceptionInterface on a network error or when the idle timeout is reached
  39. */
  40. public function isLast(): bool;
  41. /**
  42. * Returns a [status code, headers] tuple when a 1xx status code was just received.
  43. *
  44. * @throws TransportExceptionInterface on a network error or when the idle timeout is reached
  45. */
  46. public function getInformationalStatus(): ?array;
  47. /**
  48. * Returns the content of the response chunk.
  49. *
  50. * @throws TransportExceptionInterface on a network error or when the idle timeout is reached
  51. */
  52. public function getContent(): string;
  53. /**
  54. * Returns the offset of the chunk in the response body.
  55. */
  56. public function getOffset(): int;
  57. /**
  58. * In case of error, returns the message that describes it.
  59. */
  60. public function getError(): ?string;
  61. }