iclient.php 7.1 KB

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