1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (https://nette.org)
5: * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6: */
7:
8: namespace Nette\Http;
9:
10:
11: /**
12: * IHttpResponse interface.
13: */
14: interface IResponse
15: {
16: /** @var int cookie expiration: forever (23.1.2037) */
17: const PERMANENT = 2116333333;
18:
19: /** @var int cookie expiration: until the browser is closed */
20: const BROWSER = 0;
21:
22: /** HTTP 1.1 response code */
23: const
24: S100_CONTINUE = 100,
25: S101_SWITCHING_PROTOCOLS = 101,
26: S200_OK = 200,
27: S201_CREATED = 201,
28: S202_ACCEPTED = 202,
29: S203_NON_AUTHORITATIVE_INFORMATION = 203,
30: S204_NO_CONTENT = 204,
31: S205_RESET_CONTENT = 205,
32: S206_PARTIAL_CONTENT = 206,
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: S305_USE_PROXY = 305,
40: S307_TEMPORARY_REDIRECT = 307,
41: S400_BAD_REQUEST = 400,
42: S401_UNAUTHORIZED = 401,
43: S402_PAYMENT_REQUIRED = 402,
44: S403_FORBIDDEN = 403,
45: S404_NOT_FOUND = 404,
46: S405_METHOD_NOT_ALLOWED = 405,
47: S406_NOT_ACCEPTABLE = 406,
48: S407_PROXY_AUTHENTICATION_REQUIRED = 407,
49: S408_REQUEST_TIMEOUT = 408,
50: S409_CONFLICT = 409,
51: S410_GONE = 410,
52: S411_LENGTH_REQUIRED = 411,
53: S412_PRECONDITION_FAILED = 412,
54: S413_REQUEST_ENTITY_TOO_LARGE = 413,
55: S414_REQUEST_URI_TOO_LONG = 414,
56: S415_UNSUPPORTED_MEDIA_TYPE = 415,
57: S416_REQUESTED_RANGE_NOT_SATISFIABLE = 416,
58: S417_EXPECTATION_FAILED = 417,
59: S426_UPGRADE_REQUIRED = 426,
60: S500_INTERNAL_SERVER_ERROR = 500,
61: S501_NOT_IMPLEMENTED = 501,
62: S502_BAD_GATEWAY = 502,
63: S503_SERVICE_UNAVAILABLE = 503,
64: S504_GATEWAY_TIMEOUT = 504,
65: S505_HTTP_VERSION_NOT_SUPPORTED = 505;
66:
67: /**
68: * Sets HTTP response code.
69: * @param int
70: * @return void
71: */
72: function setCode($code);
73:
74: /**
75: * Returns HTTP response code.
76: * @return int
77: */
78: function getCode();
79:
80: /**
81: * Sends a HTTP header and replaces a previous one.
82: * @param string header name
83: * @param string header value
84: * @return void
85: */
86: function setHeader($name, $value);
87:
88: /**
89: * Adds HTTP header.
90: * @param string header name
91: * @param string header value
92: * @return void
93: */
94: function addHeader($name, $value);
95:
96: /**
97: * Sends a Content-type HTTP header.
98: * @param string mime-type
99: * @param string charset
100: * @return void
101: */
102: function setContentType($type, $charset = NULL);
103:
104: /**
105: * Redirects to a new URL.
106: * @param string URL
107: * @param int HTTP code
108: * @return void
109: */
110: function redirect($url, $code = self::S302_FOUND);
111:
112: /**
113: * Sets the number of seconds before a page cached on a browser expires.
114: * @param string|int|\DateTime time, value 0 means "until the browser is closed"
115: * @return void
116: */
117: function setExpiration($seconds);
118:
119: /**
120: * Checks if headers have been sent.
121: * @return bool
122: */
123: function isSent();
124:
125: /**
126: * Returns value of an HTTP header.
127: * @param string
128: * @param mixed
129: * @return mixed
130: */
131: function getHeader($header, $default = NULL);
132:
133: /**
134: * Returns a list of headers to sent.
135: * @return array (name => value)
136: */
137: function getHeaders();
138:
139: /**
140: * Sends a cookie.
141: * @param string name of the cookie
142: * @param string value
143: * @param mixed expiration as unix timestamp or number of seconds; Value 0 means "until the browser is closed"
144: * @param string
145: * @param string
146: * @param bool
147: * @param bool
148: * @return void
149: */
150: function setCookie($name, $value, $expire, $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL);
151:
152: /**
153: * Deletes a cookie.
154: * @param string name of the cookie.
155: * @param string
156: * @param string
157: * @param bool
158: * @return void
159: */
160: function deleteCookie($name, $path = NULL, $domain = NULL, $secure = NULL);
161:
162: }
163: