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