ClientInterface.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\HTTP;
  7. /**
  8. * Interface for HTTP clients
  9. *
  10. * @api
  11. * @since 100.0.2
  12. */
  13. interface ClientInterface
  14. {
  15. /**
  16. * Set request timeout
  17. *
  18. * @param int $value value in seconds
  19. * @return void
  20. */
  21. public function setTimeout($value);
  22. /**
  23. * Set request headers from hash
  24. *
  25. * @param array $headers an array of header names as keys and header values as values
  26. * @return void
  27. */
  28. public function setHeaders($headers);
  29. /**
  30. * Add header to request
  31. *
  32. * @param string $name name of the HTTP header
  33. * @param string $value value of the HTTP header
  34. * @return void
  35. */
  36. public function addHeader($name, $value);
  37. /**
  38. * Remove header from request
  39. *
  40. * @param string $name name of the HTTP header
  41. * @return void
  42. */
  43. public function removeHeader($name);
  44. /**
  45. * Set login credentials for basic authentication.
  46. *
  47. * @param string $login user identity/name
  48. * @param string $pass user password
  49. * @return void
  50. */
  51. public function setCredentials($login, $pass);
  52. /**
  53. * Add cookie to request
  54. *
  55. * @param string $name name of the cookie
  56. * @param string $value value of the cookie
  57. * @return void
  58. */
  59. public function addCookie($name, $value);
  60. /**
  61. * Remove cookie from request
  62. *
  63. * @param string $name name of the cookie
  64. * @return void
  65. */
  66. public function removeCookie($name);
  67. /**
  68. * Set request cookies from hash
  69. *
  70. * @param array $cookies an array of cookies with cookie names as keys and cookie values as value
  71. * @return void
  72. */
  73. public function setCookies($cookies);
  74. /**
  75. * Remove cookies from request
  76. *
  77. * @return void
  78. */
  79. public function removeCookies();
  80. /**
  81. * Make GET request
  82. *
  83. * @param string $uri full uri
  84. * @return array
  85. */
  86. public function get($uri);
  87. /**
  88. * Make POST request
  89. *
  90. * @param string $uri full uri
  91. * @param array|string $params POST fields array or string in case of JSON or XML data
  92. * @return void
  93. */
  94. public function post($uri, $params);
  95. /**
  96. * Get response headers
  97. *
  98. * @return array
  99. */
  100. public function getHeaders();
  101. /**
  102. * Get response body
  103. *
  104. * @return string
  105. */
  106. public function getBody();
  107. /**
  108. * Get response status code
  109. *
  110. * @return int
  111. */
  112. public function getStatus();
  113. /**
  114. * Get response cookies (k=>v)
  115. *
  116. * @return array
  117. */
  118. public function getCookies();
  119. /**
  120. * Set additional option
  121. *
  122. * @param string $key
  123. * @param string $value
  124. * @return void
  125. */
  126. public function setOption($key, $value);
  127. /**
  128. * Set additional options
  129. *
  130. * @param array $arr
  131. * @return void
  132. */
  133. public function setOptions($arr);
  134. }