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: * IHttpResponse interface.
19: *
20: * @author David Grudl
21: */
22: interface IResponse
23: {
24: /** @var int cookie expiration: forever (23.1.2037) */
25: const PERMANENT = 2116333333;
26:
27: /** @var int cookie expiration: until the browser is closed */
28: const BROWSER = 0;
29:
30: /** HTTP 1.1 response code */
31: const
32: S200_OK = 200,
33: S204_NO_CONTENT = 204,
34: S300_MULTIPLE_CHOICES = 300,
35: S301_MOVED_PERMANENTLY = 301,
36: S302_FOUND = 302,
37: S303_SEE_OTHER = 303,
38: S303_POST_GET = 303,
39: S304_NOT_MODIFIED = 304,
40: S307_TEMPORARY_REDIRECT= 307,
41: S400_BAD_REQUEST = 400,
42: S401_UNAUTHORIZED = 401,
43: S403_FORBIDDEN = 403,
44: S404_NOT_FOUND = 404,
45: S405_METHOD_NOT_ALLOWED = 405,
46: S410_GONE = 410,
47: S500_INTERNAL_SERVER_ERROR = 500,
48: S501_NOT_IMPLEMENTED = 501,
49: S503_SERVICE_UNAVAILABLE = 503;
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: * @param bool
124: * @return void
125: */
126: function setCookie($name, $value, $expire, $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL);
127:
128: /**
129: * Deletes a cookie.
130: * @param string name of the cookie.
131: * @param string
132: * @param string
133: * @param bool
134: * @return void
135: */
136: function deleteCookie($name, $path = NULL, $domain = NULL, $secure = NULL);
137:
138: }
139: