1: <?php
2:
3: /**
4: * This file is part of the Nette Framework.
5: *
6: * Copyright (c) 2004, 2010 David Grudl (http://davidgrudl.com)
7: *
8: * This source file is subject to the "Nette license", and/or
9: * GPL license. For more information please see http://nette.org
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: /**
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: