1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (https://nette.org)
5: *
6: * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
7: *
8: * For the full copyright and license information, please view
9: * the file license.txt that was distributed with this source code.
10: * @package Nette\Web
11: */
12:
13:
14:
15: /**
16: * IHttpResponse interface.
17: *
18: * @author David Grudl
19: * @package Nette\Web
20: */
21: interface IHttpResponse
22: {
23: /** @var int cookie expiration: forever (23.1.2037) */
24: const PERMANENT = 2116333333;
25:
26: /** @var int cookie expiration: until the browser is closed */
27: const BROWSER = 0;
28:
29: /**#@+ HTTP 1.1 response code */
30: const
31: S200_OK = 200,
32: S204_NO_CONTENT = 204,
33: S300_MULTIPLE_CHOICES = 300,
34: S301_MOVED_PERMANENTLY = 301,
35: S302_FOUND = 302,
36: S303_SEE_OTHER = 303,
37: S303_POST_GET = 303,
38: S304_NOT_MODIFIED = 304,
39: S307_TEMPORARY_REDIRECT= 307,
40: S400_BAD_REQUEST = 400,
41: S401_UNAUTHORIZED = 401,
42: S403_FORBIDDEN = 403,
43: S404_NOT_FOUND = 404,
44: S405_METHOD_NOT_ALLOWED = 405,
45: S410_GONE = 410,
46: S500_INTERNAL_SERVER_ERROR = 500,
47: S501_NOT_IMPLEMENTED = 501,
48: S503_SERVICE_UNAVAILABLE = 503;
49: /**#@-*/
50:
51: /**
52: * Sets HTTP response code.
53: * @param int
54: * @return void
55: */
56: function setCode($code);
57:
58: /**
59: * Returns HTTP response code.
60: * @return int
61: */
62: function getCode();
63:
64: /**
65: * Sends a HTTP header and replaces a previous one.
66: * @param string header name
67: * @param string header value
68: * @return void
69: */
70: function setHeader($name, $value);
71:
72: /**
73: * Adds HTTP header.
74: * @param string header name
75: * @param string header value
76: * @return void
77: */
78: function addHeader($name, $value);
79:
80: /**
81: * Sends a Content-type HTTP header.
82: * @param string mime-type
83: * @param string charset
84: * @return void
85: */
86: function setContentType($type, $charset = NULL);
87:
88: /**
89: * Redirects to a new URL.
90: * @param string URL
91: * @param int HTTP code
92: * @return void
93: */
94: function redirect($url, $code = self::S302_FOUND);
95:
96: /**
97: * Sets the number of seconds before a page cached on a browser expires.
98: * @param mixed timestamp or number of seconds
99: * @return void
100: */
101: function setExpiration($seconds);
102:
103: /**
104: * Checks if headers have been sent.
105: * @return bool
106: */
107: function isSent();
108:
109: /**
110: * Returns a list of headers to sent.
111: * @return array
112: */
113: function getHeaders();
114:
115: /**
116: * Sends a cookie.
117: * @param string name of the cookie
118: * @param string value
119: * @param mixed expiration as unix timestamp or number of seconds; Value 0 means "until the browser is closed"
120: * @param string
121: * @param string
122: * @param bool
123: * @return void
124: */
125: function setCookie($name, $value, $expire, $path = NULL, $domain = NULL, $secure = NULL);
126:
127: /**
128: * Deletes a cookie.
129: * @param string name of the cookie.
130: * @param string
131: * @param string
132: * @param bool
133: * @return void
134: */
135: function deleteCookie($name, $path = NULL, $domain = NULL, $secure = NULL);
136:
137: }
138: