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