RequestInterface.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /*
  3. * This file is part of the php-phantomjs.
  4. *
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. */
  8. namespace JonnyW\PhantomJs\Message;
  9. /**
  10. * PHP PhantomJs
  11. *
  12. * @author Jon Wenmoth <contact@jonnyw.me>
  13. */
  14. interface RequestInterface
  15. {
  16. const METHOD_OPTIONS = 'OPTIONS';
  17. const METHOD_GET = 'GET';
  18. const METHOD_HEAD = 'HEAD';
  19. const METHOD_POST = 'POST';
  20. const METHOD_PUT = 'PUT';
  21. const METHOD_DELETE = 'DELETE';
  22. const METHOD_PATCH = 'PATCH';
  23. /**
  24. * Set request method
  25. *
  26. * @param string $method
  27. * @return Request
  28. */
  29. public function setMethod($method);
  30. /**
  31. * Get request method
  32. *
  33. * @return string
  34. */
  35. public function getMethod();
  36. /**
  37. * Set request URL
  38. *
  39. * @param string $url
  40. * @return Request
  41. */
  42. public function setUrl($url);
  43. /**
  44. * Get request URL
  45. * - Assembles query string for GET
  46. * and HEAD requests
  47. *
  48. * @return string
  49. */
  50. public function getUrl();
  51. /**
  52. * Get content body
  53. * - Returns query string if not GET or HEAD
  54. *
  55. * @return string
  56. */
  57. public function getBody();
  58. /**
  59. * Set request data
  60. *
  61. * @param array $data
  62. * @return Request
  63. */
  64. public function setRequestData(array $data);
  65. /**
  66. * Get request data
  67. *
  68. * @param boolean $flat
  69. * @return array
  70. */
  71. public function getRequestData($flat = true);
  72. /**
  73. * Set headers
  74. *
  75. * @param array $headers
  76. * @return JonnyW\PhantomJs\Message\Request|null
  77. */
  78. public function setHeaders(array $headers);
  79. /**
  80. * Add single header
  81. *
  82. * @param string $header
  83. * @param string $value
  84. * @return Request
  85. */
  86. public function addHeader($header, $value);
  87. /**
  88. * Merge headers with existing
  89. *
  90. * @param array $headers
  91. * @return Request
  92. */
  93. public function addHeaders(array $headers);
  94. /**
  95. * Get request headers
  96. *
  97. * @param string $format
  98. * @return array
  99. */
  100. public function getHeaders($format = 'default');
  101. }