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