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