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