4 * Licensed to Jasig under one or more contributor license
5 * agreements. See the NOTICE file distributed with this work for
6 * additional information regarding copyright ownership.
8 * Jasig licenses this file to you under the Apache License,
9 * Version 2.0 (the "License"); you may not use this file except in
10 * compliance with the License. You may obtain a copy of the License at:
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 * @file CAS/Request/RequestInterface.php
23 * @category Authentication
25 * @author Adam Franco <afranco@middlebury.edu>
26 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
27 * @link https://wiki.jasig.org/display/CASC/phpCAS
31 * This interface defines a class library for performing web requests.
33 * @class CAS_Request_RequestInterface
34 * @category Authentication
36 * @author Adam Franco <afranco@middlebury.edu>
37 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
38 * @link https://wiki.jasig.org/display/CASC/phpCAS
40 interface CAS_Request_RequestInterface
43 /*********************************************************
44 * Configure the Request
45 *********************************************************/
48 * Set the URL of the Request
50 * @param string $url url to set
53 * @throws CAS_OutOfSequenceException If called after the Request has been sent.
55 public function setUrl ($url);
58 * Add a cookie to the request.
60 * @param string $name name of cookie
61 * @param string $value value of cookie
64 * @throws CAS_OutOfSequenceException If called after the Request has been sent.
66 public function addCookie ($name, $value);
69 * Add an array of cookies to the request.
70 * The cookie array is of the form
71 * array('cookie_name' => 'cookie_value', 'cookie_name2' => cookie_value2')
73 * @param array $cookies cookies to add
76 * @throws CAS_OutOfSequenceException If called after the Request has been sent.
78 public function addCookies (array $cookies);
81 * Add a header string to the request.
83 * @param string $header header to add
86 * @throws CAS_OutOfSequenceException If called after the Request has been sent.
88 public function addHeader ($header);
91 * Add an array of header strings to the request.
93 * @param array $headers headers to add
96 * @throws CAS_OutOfSequenceException If called after the Request has been sent.
98 public function addHeaders (array $headers);
101 * Make the request a POST request rather than the default GET request.
104 * @throws CAS_OutOfSequenceException If called after the Request has been sent.
106 public function makePost ();
109 * Add a POST body to the request
111 * @param string $body body to add
114 * @throws CAS_OutOfSequenceException If called after the Request has been sent.
116 public function setPostBody ($body);
120 * Specify the path to an SSL CA certificate to validate the server with.
122 * @param string $caCertPath path to cert file
123 * @param boolean $validate_cn validate CN of SSL certificate
126 * @throws CAS_OutOfSequenceException If called after the Request has been sent.
128 public function setSslCaCert ($caCertPath, $validate_cn = true);
132 /*********************************************************
133 * 2. Send the Request
134 *********************************************************/
137 * Perform the request.
139 * @return bool TRUE on success, FALSE on failure.
140 * @throws CAS_OutOfSequenceException If called multiple times.
142 public function send ();
144 /*********************************************************
145 * 3. Access the response
146 *********************************************************/
149 * Answer the headers of the response.
151 * @return array An array of header strings.
152 * @throws CAS_OutOfSequenceException If called before the Request has been sent.
154 public function getResponseHeaders ();
157 * Answer HTTP status code of the response
160 * @throws CAS_OutOfSequenceException If called before the Request has been sent.
162 public function getResponseStatusCode ();
165 * Answer the body of response.
168 * @throws CAS_OutOfSequenceException If called before the Request has been sent.
170 public function getResponseBody ();
173 * Answer a message describing any errors if the request failed.
176 * @throws CAS_OutOfSequenceException If called before the Request has been sent.
178 public function getErrorMessage ();