iclient.php 7.2 KB

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