/vendor/guzzle/http/Guzzle/Http/Message/RequestInterface.php

https://bitbucket.org/nbravo777/repo_ratchet · PHP · 341 lines · 62 code · 41 blank · 238 comment · 0 complexity · 820317fb8cb8ff967e8611c061564ad6 MD5 · raw file

  1. <?php
  2. namespace Guzzle\Http\Message;
  3. use Guzzle\Common\Collection;
  4. use Guzzle\Common\HasDispatcherInterface;
  5. use Guzzle\Http\Exception\RequestException;
  6. use Guzzle\Http\ClientInterface;
  7. use Guzzle\Http\EntityBodyInterface;
  8. use Guzzle\Http\Url;
  9. use Guzzle\Http\QueryString;
  10. /**
  11. * Generic HTTP request interface
  12. */
  13. interface RequestInterface extends MessageInterface, HasDispatcherInterface
  14. {
  15. const STATE_NEW = 'new';
  16. const STATE_COMPLETE = 'complete';
  17. const STATE_TRANSFER = 'transfer';
  18. const STATE_ERROR = 'error';
  19. const GET = 'GET';
  20. const PUT = 'PUT';
  21. const POST = 'POST';
  22. const DELETE = 'DELETE';
  23. const HEAD = 'HEAD';
  24. const CONNECT = 'CONNECT';
  25. const OPTIONS = 'OPTIONS';
  26. const TRACE = 'TRACE';
  27. const PATCH = 'PATCH';
  28. /**
  29. * @return string
  30. */
  31. public function __toString();
  32. /**
  33. * Set the client used to transport the request
  34. *
  35. * @param ClientInterface $client
  36. *
  37. * @return self
  38. */
  39. public function setClient(ClientInterface $client);
  40. /**
  41. * Get the client used to transport the request
  42. *
  43. * @return ClientInterface $client
  44. */
  45. public function getClient();
  46. /**
  47. * Set the URL of the request
  48. *
  49. * @param string $url|Url Full URL to set including query string
  50. *
  51. * @return self
  52. */
  53. public function setUrl($url);
  54. /**
  55. * Send the request
  56. *
  57. * @return Response
  58. * @throws RequestException on a request error
  59. */
  60. public function send();
  61. /**
  62. * Get the previously received {@see Response} or NULL if the request has not been sent
  63. *
  64. * @return Response|null
  65. */
  66. public function getResponse();
  67. /**
  68. * Get the collection of key value pairs that will be used as the query string in the request
  69. *
  70. * @return QueryString
  71. */
  72. public function getQuery();
  73. /**
  74. * Get the HTTP method of the request
  75. *
  76. * @return string
  77. */
  78. public function getMethod();
  79. /**
  80. * Get the URI scheme of the request (http, https, ftp, etc)
  81. *
  82. * @return string
  83. */
  84. public function getScheme();
  85. /**
  86. * Set the URI scheme of the request (http, https, ftp, etc)
  87. *
  88. * @param string $scheme Scheme to set
  89. *
  90. * @return self
  91. */
  92. public function setScheme($scheme);
  93. /**
  94. * Get the host of the request
  95. *
  96. * @return string
  97. */
  98. public function getHost();
  99. /**
  100. * Set the host of the request. Including a port in the host will modify the port of the request.
  101. *
  102. * @param string $host Host to set (e.g. www.yahoo.com, www.yahoo.com:80)
  103. *
  104. * @return self
  105. */
  106. public function setHost($host);
  107. /**
  108. * Get the HTTP protocol version of the request
  109. *
  110. * @return string
  111. */
  112. public function getProtocolVersion();
  113. /**
  114. * Set the HTTP protocol version of the request (e.g. 1.1 or 1.0)
  115. *
  116. * @param string $protocol HTTP protocol version to use with the request
  117. *
  118. * @return self
  119. */
  120. public function setProtocolVersion($protocol);
  121. /**
  122. * Get the path of the request (e.g. '/', '/index.html')
  123. *
  124. * @return string
  125. */
  126. public function getPath();
  127. /**
  128. * Set the path of the request (e.g. '/', '/index.html')
  129. *
  130. * @param string|array $path Path to set or array of segments to implode
  131. *
  132. * @return self
  133. */
  134. public function setPath($path);
  135. /**
  136. * Get the port that the request will be sent on if it has been set
  137. *
  138. * @return int|null
  139. */
  140. public function getPort();
  141. /**
  142. * Set the port that the request will be sent on
  143. *
  144. * @param int $port Port number to set
  145. *
  146. * @return self
  147. */
  148. public function setPort($port);
  149. /**
  150. * Get the username to pass in the URL if set
  151. *
  152. * @return string|null
  153. */
  154. public function getUsername();
  155. /**
  156. * Set HTTP authorization parameters
  157. *
  158. * @param string|bool $user User name or false disable authentication
  159. * @param string $password Password
  160. * @param string $scheme Authentication scheme to use (CURLAUTH_BASIC, CURLAUTH_DIGEST, etc)
  161. *
  162. * @return self
  163. * @link http://www.ietf.org/rfc/rfc2617.txt
  164. * @link http://php.net/manual/en/function.curl-setopt.php See the available options for CURLOPT_HTTPAUTH
  165. * @throws RequestException
  166. */
  167. public function setAuth($user, $password = '', $scheme = 'Basic');
  168. /**
  169. * Get the password to pass in the URL if set
  170. *
  171. * @return string|null
  172. */
  173. public function getPassword();
  174. /**
  175. * Get the resource part of the the request, including the path, query string, and fragment
  176. *
  177. * @return string
  178. */
  179. public function getResource();
  180. /**
  181. * Get the full URL of the request (e.g. 'http://www.guzzle-project.com/')
  182. *
  183. * @param bool $asObject Set to TRUE to retrieve the URL as a clone of the URL object owned by the request.
  184. *
  185. * @return string|Url
  186. */
  187. public function getUrl($asObject = false);
  188. /**
  189. * Get the state of the request. One of 'complete', 'transfer', 'new', 'error'
  190. *
  191. * @return string
  192. */
  193. public function getState();
  194. /**
  195. * Set the state of the request
  196. *
  197. * @param string $state State of the request ('complete', 'transfer', 'new', 'error')
  198. * @param array $context Contextual information about the state change
  199. *
  200. * @return self
  201. */
  202. public function setState($state, array $context = array());
  203. /**
  204. * Get the cURL options that will be applied when the cURL handle is created
  205. *
  206. * @return Collection
  207. */
  208. public function getCurlOptions();
  209. /**
  210. * The start of a response has been received for a request and the request is still in progress
  211. *
  212. * @param Response $response Response that has been received so far
  213. *
  214. * @return self
  215. */
  216. public function startResponse(Response $response);
  217. /**
  218. * Set the EntityBody that will hold a successful response message's entity body.
  219. *
  220. * This method should be invoked when you need to send the response's entity body somewhere other than the normal
  221. * php://temp buffer. For example, you can send the entity body to a socket, file, or some other custom stream.
  222. *
  223. * @param EntityBodyInterface|string|resource $body Response body object. Pass a string to attempt to store the
  224. * response body in a local file.
  225. * @return Request
  226. */
  227. public function setResponseBody($body);
  228. /**
  229. * Get the EntityBody that will hold the resulting response message's entity body. This response body will only
  230. * be used for successful responses. Intermediate responses (e.g. redirects) will not use the targeted response
  231. * body.
  232. *
  233. * @return EntityBodyInterface
  234. */
  235. public function getResponseBody();
  236. /**
  237. * Manually set a response for the request.
  238. *
  239. * This method is useful for specifying a mock response for the request or setting the response using a cache.
  240. * Manually setting a response will bypass the actual sending of a request.
  241. *
  242. * @param Response $response Response object to set
  243. * @param bool $queued Set to TRUE to keep the request in a state of not having been sent, but queue the
  244. * response for send()
  245. *
  246. * @return self Returns a reference to the object.
  247. */
  248. public function setResponse(Response $response, $queued = false);
  249. /**
  250. * Get an array of Cookies
  251. *
  252. * @return array
  253. */
  254. public function getCookies();
  255. /**
  256. * Get a cookie value by name
  257. *
  258. * @param string $name Cookie to retrieve
  259. *
  260. * @return null|string
  261. */
  262. public function getCookie($name);
  263. /**
  264. * Add a Cookie value by name to the Cookie header
  265. *
  266. * @param string $name Name of the cookie to add
  267. * @param string $value Value to set
  268. *
  269. * @return self
  270. */
  271. public function addCookie($name, $value);
  272. /**
  273. * Remove a specific cookie value by name
  274. *
  275. * @param string $name Cookie to remove by name
  276. *
  277. * @return self
  278. */
  279. public function removeCookie($name);
  280. /**
  281. * Returns whether or not the request can be cached based on the request headers
  282. *
  283. * @return bool
  284. */
  285. public function canCache();
  286. /**
  287. * Set whether or not the request is a request that resulted from a redirect
  288. *
  289. * @param bool $isRedirect
  290. *
  291. * @return self
  292. */
  293. public function setIsRedirect($isRedirect);
  294. /**
  295. * Check whether or not the request is a request that resulted from a redirect
  296. *
  297. * @return bool
  298. */
  299. public function isRedirect();
  300. }