You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.0 KiB

3 years ago
  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. }