HttpInterface.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\App\Response;
  7. /**
  8. * HTTP response interface
  9. *
  10. * @api
  11. * @since 100.0.2
  12. */
  13. interface HttpInterface extends \Magento\Framework\App\ResponseInterface
  14. {
  15. /**
  16. * Set HTTP response code
  17. *
  18. * @param int $code
  19. * @return void
  20. */
  21. public function setHttpResponseCode($code);
  22. /**
  23. * Get HTTP response code
  24. *
  25. * @return int
  26. * @since 101.0.0
  27. */
  28. public function getHttpResponseCode();
  29. /**
  30. * Set a header
  31. *
  32. * If $replace is true, replaces any headers already defined with that $name.
  33. *
  34. * @param string $name
  35. * @param string $value
  36. * @param boolean $replace
  37. * @return self
  38. * @since 101.0.0
  39. */
  40. public function setHeader($name, $value, $replace = false);
  41. /**
  42. * Get header value by name
  43. *
  44. * Returns first found header by passed name.
  45. * If header with specified name was not found returns false.
  46. *
  47. * @param string $name
  48. * @return \Zend\Http\Header\HeaderInterface|bool
  49. * @since 101.0.0
  50. */
  51. public function getHeader($name);
  52. /**
  53. * Remove header by name from header stack
  54. *
  55. * @param string $name
  56. * @return self
  57. * @since 101.0.0
  58. */
  59. public function clearHeader($name);
  60. /**
  61. * Allow granular setting of HTTP response status code, version and phrase
  62. *
  63. * For example, a HTTP response as the following:
  64. * HTTP 200 1.1 Your response has been served
  65. * Can be set with the arguments
  66. * $httpCode = 200
  67. * $version = 1.1
  68. * $phrase = 'Your response has been served'
  69. *
  70. * @param int|string $httpCode
  71. * @param null|int|string $version
  72. * @param null|string $phrase
  73. * @return self
  74. * @since 101.0.0
  75. */
  76. public function setStatusHeader($httpCode, $version = null, $phrase = null);
  77. /**
  78. * Append the given string to the response body
  79. *
  80. * @param string $value
  81. * @return self
  82. * @since 101.0.0
  83. */
  84. public function appendBody($value);
  85. /**
  86. * Set the response body to the given value
  87. *
  88. * Any previously set contents will be replaced by the new content.
  89. *
  90. * @param string $value
  91. * @return self
  92. * @since 101.0.0
  93. */
  94. public function setBody($value);
  95. /**
  96. * Set redirect URL
  97. *
  98. * Sets Location header and response code. Forces replacement of any prior redirects.
  99. *
  100. * @param string $url
  101. * @param int $code
  102. * @return self
  103. * @since 101.0.0
  104. */
  105. public function setRedirect($url, $code = 302);
  106. }