RequestInterface.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. declare(strict_types=1);
  3. namespace Sabre\HTTP;
  4. /**
  5. * The RequestInterface represents a HTTP request.
  6. *
  7. * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
  8. * @author Evert Pot (http://evertpot.com/)
  9. * @license http://sabre.io/license/ Modified BSD License
  10. */
  11. interface RequestInterface extends MessageInterface
  12. {
  13. /**
  14. * Returns the current HTTP method.
  15. */
  16. public function getMethod(): string;
  17. /**
  18. * Sets the HTTP method.
  19. */
  20. public function setMethod(string $method);
  21. /**
  22. * Returns the request url.
  23. */
  24. public function getUrl(): string;
  25. /**
  26. * Sets the request url.
  27. */
  28. public function setUrl(string $url);
  29. /**
  30. * Returns the absolute url.
  31. */
  32. public function getAbsoluteUrl(): string;
  33. /**
  34. * Sets the absolute url.
  35. */
  36. public function setAbsoluteUrl(string $url);
  37. /**
  38. * Returns the current base url.
  39. */
  40. public function getBaseUrl(): string;
  41. /**
  42. * Sets a base url.
  43. *
  44. * This url is used for relative path calculations.
  45. *
  46. * The base url should default to /
  47. */
  48. public function setBaseUrl(string $url);
  49. /**
  50. * Returns the relative path.
  51. *
  52. * This is being calculated using the base url. This path will not start
  53. * with a slash, so it will always return something like
  54. * 'example/path.html'.
  55. *
  56. * If the full path is equal to the base url, this method will return an
  57. * empty string.
  58. *
  59. * This method will also urldecode the path, and if the url was encoded as
  60. * ISO-8859-1, it will convert it to UTF-8.
  61. *
  62. * If the path is outside of the base url, a LogicException will be thrown.
  63. */
  64. public function getPath(): string;
  65. /**
  66. * Returns the list of query parameters.
  67. *
  68. * This is equivalent to PHP's $_GET superglobal.
  69. */
  70. public function getQueryParameters(): array;
  71. /**
  72. * Returns the POST data.
  73. *
  74. * This is equivalent to PHP's $_POST superglobal.
  75. */
  76. public function getPostData(): array;
  77. /**
  78. * Sets the post data.
  79. *
  80. * This is equivalent to PHP's $_POST superglobal.
  81. *
  82. * This would not have been needed, if POST data was accessible as
  83. * php://input, but unfortunately we need to special case it.
  84. */
  85. public function setPostData(array $postData);
  86. /**
  87. * Returns an item from the _SERVER array.
  88. *
  89. * If the value does not exist in the array, null is returned.
  90. *
  91. * @return string|null
  92. */
  93. public function getRawServerValue(string $valueName);
  94. /**
  95. * Sets the _SERVER array.
  96. */
  97. public function setRawServerData(array $data);
  98. }