Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Psr\Http\Message;
|
Chris@0
|
4
|
Chris@0
|
5 /**
|
Chris@0
|
6 * Representation of an outgoing, server-side response.
|
Chris@0
|
7 *
|
Chris@0
|
8 * Per the HTTP specification, this interface includes properties for
|
Chris@0
|
9 * each of the following:
|
Chris@0
|
10 *
|
Chris@0
|
11 * - Protocol version
|
Chris@0
|
12 * - Status code and reason phrase
|
Chris@0
|
13 * - Headers
|
Chris@0
|
14 * - Message body
|
Chris@0
|
15 *
|
Chris@0
|
16 * Responses are considered immutable; all methods that might change state MUST
|
Chris@0
|
17 * be implemented such that they retain the internal state of the current
|
Chris@0
|
18 * message and return an instance that contains the changed state.
|
Chris@0
|
19 */
|
Chris@0
|
20 interface ResponseInterface extends MessageInterface
|
Chris@0
|
21 {
|
Chris@0
|
22 /**
|
Chris@0
|
23 * Gets the response status code.
|
Chris@0
|
24 *
|
Chris@0
|
25 * The status code is a 3-digit integer result code of the server's attempt
|
Chris@0
|
26 * to understand and satisfy the request.
|
Chris@0
|
27 *
|
Chris@0
|
28 * @return int Status code.
|
Chris@0
|
29 */
|
Chris@0
|
30 public function getStatusCode();
|
Chris@0
|
31
|
Chris@0
|
32 /**
|
Chris@0
|
33 * Return an instance with the specified status code and, optionally, reason phrase.
|
Chris@0
|
34 *
|
Chris@0
|
35 * If no reason phrase is specified, implementations MAY choose to default
|
Chris@0
|
36 * to the RFC 7231 or IANA recommended reason phrase for the response's
|
Chris@0
|
37 * status code.
|
Chris@0
|
38 *
|
Chris@0
|
39 * This method MUST be implemented in such a way as to retain the
|
Chris@0
|
40 * immutability of the message, and MUST return an instance that has the
|
Chris@0
|
41 * updated status and reason phrase.
|
Chris@0
|
42 *
|
Chris@0
|
43 * @link http://tools.ietf.org/html/rfc7231#section-6
|
Chris@0
|
44 * @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
|
Chris@0
|
45 * @param int $code The 3-digit integer result code to set.
|
Chris@0
|
46 * @param string $reasonPhrase The reason phrase to use with the
|
Chris@0
|
47 * provided status code; if none is provided, implementations MAY
|
Chris@0
|
48 * use the defaults as suggested in the HTTP specification.
|
Chris@0
|
49 * @return static
|
Chris@0
|
50 * @throws \InvalidArgumentException For invalid status code arguments.
|
Chris@0
|
51 */
|
Chris@0
|
52 public function withStatus($code, $reasonPhrase = '');
|
Chris@0
|
53
|
Chris@0
|
54 /**
|
Chris@0
|
55 * Gets the response reason phrase associated with the status code.
|
Chris@0
|
56 *
|
Chris@0
|
57 * Because a reason phrase is not a required element in a response
|
Chris@0
|
58 * status line, the reason phrase value MAY be null. Implementations MAY
|
Chris@0
|
59 * choose to return the default RFC 7231 recommended reason phrase (or those
|
Chris@0
|
60 * listed in the IANA HTTP Status Code Registry) for the response's
|
Chris@0
|
61 * status code.
|
Chris@0
|
62 *
|
Chris@0
|
63 * @link http://tools.ietf.org/html/rfc7231#section-6
|
Chris@0
|
64 * @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
|
Chris@0
|
65 * @return string Reason phrase; must return an empty string if none present.
|
Chris@0
|
66 */
|
Chris@0
|
67 public function getReasonPhrase();
|
Chris@0
|
68 }
|