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: */
11:
12: namespace Nette\Web;
13:
14: use Nette;
15:
16:
17:
18: /**
19: * IHttpResponse interface.
20: *
21: * @author David Grudl
22: */
23: interface IHttpResponse
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: /**
54: * Sets HTTP response code.
55: * @param int
56: * @return void
57: */
58: function setCode($code);
59:
60: /**
61: * Returns HTTP response code.
62: * @return int
63: */
64: function getCode();
65:
66: /**
67: * Sends a HTTP header and replaces a previous one.
68: * @param string header name
69: * @param string header value
70: * @return void
71: */
72: function setHeader($name, $value);
73:
74: /**
75: * Adds HTTP header.
76: * @param string header name
77: * @param string header value
78: * @return void
79: */
80: function addHeader($name, $value);
81:
82: /**
83: * Sends a Content-type HTTP header.
84: * @param string mime-type
85: * @param string charset
86: * @return void
87: */
88: function setContentType($type, $charset = NULL);
89:
90: /**
91: * Redirects to a new URL.
92: * @param string URL
93: * @param int HTTP code
94: * @return void
95: */
96: function redirect($url, $code = self::S302_FOUND);
97:
98: /**
99: * Sets the number of seconds before a page cached on a browser expires.
100: * @param mixed timestamp or number of seconds
101: * @return void
102: */
103: function setExpiration($seconds);
104:
105: /**
106: * Checks if headers have been sent.
107: * @return bool
108: */
109: function isSent();
110:
111: /**
112: * Returns a list of headers to sent.
113: * @return array
114: */
115: function getHeaders();
116:
117: /**
118: * Sends a cookie.
119: * @param string name of the cookie
120: * @param string value
121: * @param mixed expiration as unix timestamp or number of seconds; Value 0 means "until the browser is closed"
122: * @param string
123: * @param string
124: * @param bool
125: * @return void
126: */
127: function setCookie($name, $value, $expire, $path = NULL, $domain = NULL, $secure = 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: