IClient.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Lukas Reschke <lukas@statuscode.ch>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. *
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OCP\Http\Client;
  24. /**
  25. * Interface IClient
  26. *
  27. * @package OCP\Http
  28. * @since 8.1.0
  29. */
  30. interface IClient {
  31. /**
  32. * Sends a GET request
  33. * @param string $uri
  34. * @param array $options Array such as
  35. * 'query' => [
  36. * 'field' => 'abc',
  37. * 'other_field' => '123',
  38. * 'file_name' => fopen('/path/to/file', 'r'),
  39. * ],
  40. * 'headers' => [
  41. * 'foo' => 'bar',
  42. * ],
  43. * 'cookies' => ['
  44. * 'foo' => 'bar',
  45. * ],
  46. * 'allow_redirects' => [
  47. * 'max' => 10, // allow at most 10 redirects.
  48. * 'strict' => true, // use "strict" RFC compliant redirects.
  49. * 'referer' => true, // add a Referer header
  50. * 'protocols' => ['https'] // only allow https URLs
  51. * ],
  52. * 'save_to' => '/path/to/file', // save to a file or a stream
  53. * 'verify' => true, // bool or string to CA file
  54. * 'debug' => true,
  55. * @return IResponse
  56. * @throws \Exception If the request could not get completed
  57. * @since 8.1.0
  58. */
  59. public function get($uri, array $options = []);
  60. /**
  61. * Sends a HEAD request
  62. * @param string $uri
  63. * @param array $options Array such as
  64. * 'headers' => [
  65. * 'foo' => 'bar',
  66. * ],
  67. * 'cookies' => ['
  68. * 'foo' => 'bar',
  69. * ],
  70. * 'allow_redirects' => [
  71. * 'max' => 10, // allow at most 10 redirects.
  72. * 'strict' => true, // use "strict" RFC compliant redirects.
  73. * 'referer' => true, // add a Referer header
  74. * 'protocols' => ['https'] // only allow https URLs
  75. * ],
  76. * 'save_to' => '/path/to/file', // save to a file or a stream
  77. * 'verify' => true, // bool or string to CA file
  78. * 'debug' => true,
  79. * @return IResponse
  80. * @throws \Exception If the request could not get completed
  81. * @since 8.1.0
  82. */
  83. public function head($uri, $options = []);
  84. /**
  85. * Sends a POST request
  86. * @param string $uri
  87. * @param array $options Array such as
  88. * 'body' => [
  89. * 'field' => 'abc',
  90. * 'other_field' => '123',
  91. * 'file_name' => fopen('/path/to/file', 'r'),
  92. * ],
  93. * 'headers' => [
  94. * 'foo' => 'bar',
  95. * ],
  96. * 'cookies' => ['
  97. * 'foo' => 'bar',
  98. * ],
  99. * 'allow_redirects' => [
  100. * 'max' => 10, // allow at most 10 redirects.
  101. * 'strict' => true, // use "strict" RFC compliant redirects.
  102. * 'referer' => true, // add a Referer header
  103. * 'protocols' => ['https'] // only allow https URLs
  104. * ],
  105. * 'save_to' => '/path/to/file', // save to a file or a stream
  106. * 'verify' => true, // bool or string to CA file
  107. * 'debug' => true,
  108. * @return IResponse
  109. * @throws \Exception If the request could not get completed
  110. * @since 8.1.0
  111. */
  112. public function post($uri, array $options = []);
  113. /**
  114. * Sends a PUT request
  115. * @param string $uri
  116. * @param array $options Array such as
  117. * 'body' => [
  118. * 'field' => 'abc',
  119. * 'other_field' => '123',
  120. * 'file_name' => fopen('/path/to/file', 'r'),
  121. * ],
  122. * 'headers' => [
  123. * 'foo' => 'bar',
  124. * ],
  125. * 'cookies' => ['
  126. * 'foo' => 'bar',
  127. * ],
  128. * 'allow_redirects' => [
  129. * 'max' => 10, // allow at most 10 redirects.
  130. * 'strict' => true, // use "strict" RFC compliant redirects.
  131. * 'referer' => true, // add a Referer header
  132. * 'protocols' => ['https'] // only allow https URLs
  133. * ],
  134. * 'save_to' => '/path/to/file', // save to a file or a stream
  135. * 'verify' => true, // bool or string to CA file
  136. * 'debug' => true,
  137. * @return IResponse
  138. * @throws \Exception If the request could not get completed
  139. * @since 8.1.0
  140. */
  141. public function put($uri, array $options = []);
  142. /**
  143. * Sends a DELETE request
  144. * @param string $uri
  145. * @param array $options Array such as
  146. * 'body' => [
  147. * 'field' => 'abc',
  148. * 'other_field' => '123',
  149. * 'file_name' => fopen('/path/to/file', 'r'),
  150. * ],
  151. * 'headers' => [
  152. * 'foo' => 'bar',
  153. * ],
  154. * 'cookies' => ['
  155. * 'foo' => 'bar',
  156. * ],
  157. * 'allow_redirects' => [
  158. * 'max' => 10, // allow at most 10 redirects.
  159. * 'strict' => true, // use "strict" RFC compliant redirects.
  160. * 'referer' => true, // add a Referer header
  161. * 'protocols' => ['https'] // only allow https URLs
  162. * ],
  163. * 'save_to' => '/path/to/file', // save to a file or a stream
  164. * 'verify' => true, // bool or string to CA file
  165. * 'debug' => true,
  166. * @return IResponse
  167. * @throws \Exception If the request could not get completed
  168. * @since 8.1.0
  169. */
  170. public function delete($uri, array $options = []);
  171. /**
  172. * Sends a options request
  173. * @param string $uri
  174. * @param array $options Array such as
  175. * 'body' => [
  176. * 'field' => 'abc',
  177. * 'other_field' => '123',
  178. * 'file_name' => fopen('/path/to/file', 'r'),
  179. * ],
  180. * 'headers' => [
  181. * 'foo' => 'bar',
  182. * ],
  183. * 'cookies' => ['
  184. * 'foo' => 'bar',
  185. * ],
  186. * 'allow_redirects' => [
  187. * 'max' => 10, // allow at most 10 redirects.
  188. * 'strict' => true, // use "strict" RFC compliant redirects.
  189. * 'referer' => true, // add a Referer header
  190. * 'protocols' => ['https'] // only allow https URLs
  191. * ],
  192. * 'save_to' => '/path/to/file', // save to a file or a stream
  193. * 'verify' => true, // bool or string to CA file
  194. * 'debug' => true,
  195. * @return IResponse
  196. * @throws \Exception If the request could not get completed
  197. * @since 8.1.0
  198. */
  199. public function options($uri, array $options = []);
  200. }