RequestInterface.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?php
  2. /**
  3. * Licensed to Jasig under one or more contributor license
  4. * agreements. See the NOTICE file distributed with this work for
  5. * additional information regarding copyright ownership.
  6. *
  7. * Jasig licenses this file to you under the Apache License,
  8. * Version 2.0 (the "License"); you may not use this file except in
  9. * compliance with the License. You may obtain a copy of the License at:
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * PHP Version 5
  20. *
  21. * @file CAS/Request/RequestInterface.php
  22. * @category Authentication
  23. * @package PhpCAS
  24. * @author Adam Franco <afranco@middlebury.edu>
  25. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  26. * @link https://wiki.jasig.org/display/CASC/phpCAS
  27. */
  28. /**
  29. * This interface defines a class library for performing web requests.
  30. *
  31. * @class CAS_Request_RequestInterface
  32. * @category Authentication
  33. * @package PhpCAS
  34. * @author Adam Franco <afranco@middlebury.edu>
  35. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  36. * @link https://wiki.jasig.org/display/CASC/phpCAS
  37. */
  38. interface CAS_Request_RequestInterface
  39. {
  40. /*********************************************************
  41. * Configure the Request
  42. *********************************************************/
  43. /**
  44. * Set the URL of the Request
  45. *
  46. * @param string $url url to set
  47. *
  48. * @return void
  49. * @throws CAS_OutOfSequenceException If called after the Request has been sent.
  50. */
  51. public function setUrl ($url);
  52. /**
  53. * Add a cookie to the request.
  54. *
  55. * @param string $name name of cookie
  56. * @param string $value value of cookie
  57. *
  58. * @return void
  59. * @throws CAS_OutOfSequenceException If called after the Request has been sent.
  60. */
  61. public function addCookie ($name, $value);
  62. /**
  63. * Add an array of cookies to the request.
  64. * The cookie array is of the form
  65. * array('cookie_name' => 'cookie_value', 'cookie_name2' => cookie_value2')
  66. *
  67. * @param array $cookies cookies to add
  68. *
  69. * @return void
  70. * @throws CAS_OutOfSequenceException If called after the Request has been sent.
  71. */
  72. public function addCookies (array $cookies);
  73. /**
  74. * Add a header string to the request.
  75. *
  76. * @param string $header header to add
  77. *
  78. * @return void
  79. * @throws CAS_OutOfSequenceException If called after the Request has been sent.
  80. */
  81. public function addHeader ($header);
  82. /**
  83. * Add an array of header strings to the request.
  84. *
  85. * @param array $headers headers to add
  86. *
  87. * @return void
  88. * @throws CAS_OutOfSequenceException If called after the Request has been sent.
  89. */
  90. public function addHeaders (array $headers);
  91. /**
  92. * Make the request a POST request rather than the default GET request.
  93. *
  94. * @return void
  95. * @throws CAS_OutOfSequenceException If called after the Request has been sent.
  96. */
  97. public function makePost ();
  98. /**
  99. * Add a POST body to the request
  100. *
  101. * @param string $body body to add
  102. *
  103. * @return void
  104. * @throws CAS_OutOfSequenceException If called after the Request has been sent.
  105. */
  106. public function setPostBody ($body);
  107. /**
  108. * Specify the path to an SSL CA certificate to validate the server with.
  109. *
  110. * @param string $caCertPath path to cert file
  111. * @param boolean $validate_cn validate CN of SSL certificate
  112. *
  113. * @return void
  114. * @throws CAS_OutOfSequenceException If called after the Request has been sent.
  115. */
  116. public function setSslCaCert ($caCertPath, $validate_cn = true);
  117. /*********************************************************
  118. * 2. Send the Request
  119. *********************************************************/
  120. /**
  121. * Perform the request.
  122. *
  123. * @return bool TRUE on success, FALSE on failure.
  124. * @throws CAS_OutOfSequenceException If called multiple times.
  125. */
  126. public function send ();
  127. /*********************************************************
  128. * 3. Access the response
  129. *********************************************************/
  130. /**
  131. * Answer the headers of the response.
  132. *
  133. * @return array An array of header strings.
  134. * @throws CAS_OutOfSequenceException If called before the Request has been sent.
  135. */
  136. public function getResponseHeaders ();
  137. /**
  138. * Answer HTTP status code of the response
  139. *
  140. * @return int
  141. * @throws CAS_OutOfSequenceException If called before the Request has been sent.
  142. */
  143. public function getResponseStatusCode ();
  144. /**
  145. * Answer the body of response.
  146. *
  147. * @return string
  148. * @throws CAS_OutOfSequenceException If called before the Request has been sent.
  149. */
  150. public function getResponseBody ();
  151. /**
  152. * Answer a message describing any errors if the request failed.
  153. *
  154. * @return string
  155. * @throws CAS_OutOfSequenceException If called before the Request has been sent.
  156. */
  157. public function getErrorMessage ();
  158. }