1
2/*
3 +------------------------------------------------------------------------+
4 | Phalcon Framework                                                      |
5 +------------------------------------------------------------------------+
6 | Copyright (c) 2011-2017 Phalcon Team (https://phalconphp.com)          |
7 +------------------------------------------------------------------------+
8 | This source file is subject to the New BSD License that is bundled     |
9 | with this package in the file LICENSE.txt.                             |
10 |                                                                        |
11 | If you did not receive a copy of the license and are unable to         |
12 | obtain it through the world-wide-web, please send an email             |
13 | to license@phalconphp.com so we can send you a copy immediately.       |
14 +------------------------------------------------------------------------+
15 | Authors: Andres Gutierrez <andres@phalconphp.com>                      |
16 |          Eduar Carvajal <eduar@phalconphp.com>                         |
17 +------------------------------------------------------------------------+
18 */
19
20namespace Phalcon\Http;
21
22/**
23 * Phalcon\Http\RequestInterface
24 *
25 * Interface for Phalcon\Http\Request
26 */
27interface RequestInterface
28{
29
30	/**
31	 * Gets a variable from the $_REQUEST superglobal applying filters if needed
32	 *
33	 * @param string name
34	 * @param string|array filters
35	 * @param mixed defaultValue
36	 * @return mixed
37	 */
38	public function get(string! name = null, filters = null, defaultValue = null);
39
40	/**
41	 * Gets a variable from the $_POST superglobal applying filters if needed
42	 *
43	 * @param string name
44	 * @param string|array filters
45	 * @param mixed defaultValue
46	 * @return mixed
47	 */
48	public function getPost(string! name = null, filters = null, defaultValue = null);
49
50	/**
51	 * Gets variable from $_GET superglobal applying filters if needed
52	 *
53	 * @param string name
54	 * @param string|array filters
55	 * @param mixed defaultValue
56	 * @return mixed
57	 */
58	public function getQuery(string! name = null, filters = null, defaultValue = null);
59
60	/**
61	 * Gets variable from $_SERVER superglobal
62	 *
63	 * @param string name
64	 * @return mixed
65	 */
66	public function getServer(string! name);
67
68	/**
69	 * Checks whether $_REQUEST superglobal has certain index
70	 */
71	public function has(string! name) -> boolean;
72
73	/**
74	 * Checks whether $_POST superglobal has certain index
75	 */
76	public function hasPost(string! name) -> boolean;
77
78	/**
79	 * Checks whether the PUT data has certain index
80	 */
81	public function hasPut(string! name) -> boolean;
82
83	/**
84	 * Checks whether $_GET superglobal has certain index
85	 */
86	public function hasQuery(string! name) -> boolean;
87
88	/**
89	 * Checks whether $_SERVER superglobal has certain index
90	 */
91	public function hasServer(string! name) -> boolean;
92
93	/**
94	 * Gets HTTP header from request data
95	 */
96	public function getHeader(string! header) -> string;
97
98	/**
99	 * Gets HTTP schema (http/https)
100	 */
101	public function getScheme() -> string;
102
103	/**
104	 * Checks whether request has been made using ajax. Checks if $_SERVER["HTTP_X_REQUESTED_WITH"] === "XMLHttpRequest"
105	 */
106	public function isAjax() -> boolean;
107
108	/**
109	 * Checks whether request has been made using SOAP
110	 */
111	public function isSoapRequested() -> boolean;
112
113	/**
114	 * Checks whether request has been made using any secure layer
115	 */
116	public function isSecureRequest() -> boolean;
117
118	/**
119	 * Gets HTTP raw request body
120	 */
121	public function getRawBody() -> string;
122
123	/**
124	 * Gets active server address IP
125	 */
126	public function getServerAddress() -> string;
127
128	/**
129	 * Gets active server name
130	 */
131	public function getServerName() -> string;
132
133	/**
134	 * Gets host name used by the request
135	 */
136	public function getHttpHost() -> string;
137
138	/**
139	 * Gets information about the port on which the request is made
140	 */
141	public function getPort() -> int;
142
143	/**
144	 * Gets most possibly client IPv4 Address. This methods searches in
145	 * $_SERVER["REMOTE_ADDR"] and optionally in $_SERVER["HTTP_X_FORWARDED_FOR"]
146	 */
147	public function getClientAddress(boolean trustForwardedHeader = false) -> string | boolean;
148
149	/**
150	 * Gets HTTP method which request has been made
151	 */
152	public function getMethod() -> string;
153
154	/**
155	 * Gets HTTP user agent used to made the request
156	 */
157	public function getUserAgent() -> string;
158
159	/**
160	 * Check if HTTP method match any of the passed methods
161	 *
162	 * @param string|array methods
163	 * @return boolean
164	 */
165	public function isMethod(methods, boolean strict = false) -> boolean;
166
167	/**
168	 * Checks whether HTTP method is POST. if $_SERVER["REQUEST_METHOD"] === "POST"
169	 */
170	public function isPost() -> boolean;
171
172	/**
173	 * Checks whether HTTP method is GET. if $_SERVER["REQUEST_METHOD"] === "GET"
174	 */
175	public function isGet() -> boolean;
176
177	/**
178	 * Checks whether HTTP method is PUT. if $_SERVER["REQUEST_METHOD"] === "PUT"
179	 */
180	public function isPut() -> boolean;
181
182	/**
183	 * Checks whether HTTP method is HEAD. if $_SERVER["REQUEST_METHOD"] === "HEAD"
184	 */
185	public function isHead() -> boolean;
186
187	/**
188	 * Checks whether HTTP method is DELETE. if $_SERVER["REQUEST_METHOD"] === "DELETE"
189	 */
190	public function isDelete() -> boolean;
191
192	/**
193	 * Checks whether HTTP method is OPTIONS. if $_SERVER["REQUEST_METHOD"] === "OPTIONS"
194	 */
195	public function isOptions() -> boolean;
196
197	/**
198	 * Checks whether HTTP method is PURGE (Squid and Varnish support). if $_SERVER["REQUEST_METHOD"] === "PURGE"
199	 */
200	public function isPurge() -> boolean;
201
202	/**
203	 * Checks whether HTTP method is TRACE. if $_SERVER["REQUEST_METHOD"] === "TRACE"
204	 */
205	public function isTrace() -> boolean;
206
207	/**
208	 * Checks whether HTTP method is CONNECT. if $_SERVER["REQUEST_METHOD"] === "CONNECT"
209	 */
210	public function isConnect() -> boolean;
211
212	/**
213	 * Checks whether request include attached files
214	 *
215	 * @param boolean onlySuccessful
216	 * @return int
217	 */
218	public function hasFiles(boolean onlySuccessful = false);
219	/**
220	 * Gets attached files as Phalcon\Http\Request\FileInterface compatible instances
221	 */
222	public function getUploadedFiles(boolean onlySuccessful = false) -> <\Phalcon\Http\Request\FileInterface[]>;
223
224	/**
225	 * Gets web page that refers active request. ie: http://www.google.com
226	 */
227	public function getHTTPReferer() -> string;
228
229	/**
230	 * Gets array with mime/types and their quality accepted by the browser/client from $_SERVER["HTTP_ACCEPT"]
231	 */
232	public function getAcceptableContent() -> array;
233
234	/**
235	 * Gets best mime/type accepted by the browser/client from $_SERVER["HTTP_ACCEPT"]
236	 */
237	public function getBestAccept() -> string;
238
239	/**
240	 * Gets charsets array and their quality accepted by the browser/client from $_SERVER["HTTP_ACCEPT_CHARSET"]
241	 */
242	public function getClientCharsets() -> array;
243
244	/**
245	 * Gets best charset accepted by the browser/client from $_SERVER["HTTP_ACCEPT_CHARSET"]
246	 */
247	public function getBestCharset() -> string;
248
249	/**
250	 * Gets languages array and their quality accepted by the browser/client from _SERVER["HTTP_ACCEPT_LANGUAGE"]
251	 */
252	public function getLanguages() -> array;
253
254	/**
255	 * Gets best language accepted by the browser/client from $_SERVER["HTTP_ACCEPT_LANGUAGE"]
256	 */
257	public function getBestLanguage() -> string;
258
259	/**
260	 * Gets auth info accepted by the browser/client from $_SERVER["PHP_AUTH_USER"]
261	 *
262	 * @return array
263	 */
264	public function getBasicAuth();
265
266	/**
267	 * Gets auth info accepted by the browser/client from $_SERVER["PHP_AUTH_DIGEST"]
268	 */
269	public function getDigestAuth() -> array;
270}
271