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