EntityBodyInterface.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace Guzzle\Http;
  3. use Guzzle\Stream\StreamInterface;
  4. /**
  5. * Entity body used with an HTTP request or response
  6. */
  7. interface EntityBodyInterface extends StreamInterface
  8. {
  9. /**
  10. * Specify a custom callback used to rewind a non-seekable stream. This can be useful entity enclosing requests
  11. * that are redirected.
  12. *
  13. * @param mixed $callable Callable to invoke to rewind a non-seekable stream. The callback must accept an
  14. * EntityBodyInterface object, perform the rewind if possible, and return a boolean
  15. * representing whether or not the rewind was successful.
  16. * @return self
  17. */
  18. public function setRewindFunction($callable);
  19. /**
  20. * If the stream is readable, compress the data in the stream using deflate compression. The uncompressed stream is
  21. * then closed, and the compressed stream then becomes the wrapped stream.
  22. *
  23. * @param string $filter Compression filter
  24. *
  25. * @return bool Returns TRUE on success or FALSE on failure
  26. */
  27. public function compress($filter = 'zlib.deflate');
  28. /**
  29. * Decompress a deflated string. Once uncompressed, the uncompressed string is then used as the wrapped stream.
  30. *
  31. * @param string $filter De-compression filter
  32. *
  33. * @return bool Returns TRUE on success or FALSE on failure
  34. */
  35. public function uncompress($filter = 'zlib.inflate');
  36. /**
  37. * Get the Content-Length of the entity body if possible (alias of getSize)
  38. *
  39. * @return int|bool Returns the Content-Length or false on failure
  40. */
  41. public function getContentLength();
  42. /**
  43. * Guess the Content-Type of a local stream
  44. *
  45. * @return string|null
  46. * @see http://www.php.net/manual/en/function.finfo-open.php
  47. */
  48. public function getContentType();
  49. /**
  50. * Get an MD5 checksum of the stream's contents
  51. *
  52. * @param bool $rawOutput Whether or not to use raw output
  53. * @param bool $base64Encode Whether or not to base64 encode raw output (only if raw output is true)
  54. *
  55. * @return bool|string Returns an MD5 string on success or FALSE on failure
  56. */
  57. public function getContentMd5($rawOutput = false, $base64Encode = false);
  58. /**
  59. * Get the Content-Encoding of the EntityBody
  60. *
  61. * @return bool|string
  62. */
  63. public function getContentEncoding();
  64. }