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