1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (https://nette.org)
5: * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6: */
7:
8: namespace Nette\Http;
9:
10:
11: /**
12: * IHttpRequest provides access scheme for request sent via HTTP.
13: */
14: interface IRequest
15: {
16: /** HTTP request method */
17: const
18: GET = 'GET',
19: POST = 'POST',
20: HEAD = 'HEAD',
21: PUT = 'PUT',
22: DELETE = 'DELETE',
23: PATCH = 'PATCH',
24: OPTIONS = 'OPTIONS';
25:
26: /**
27: * Returns URL object.
28: * @return UrlScript
29: */
30: function getUrl();
31:
32: /********************* query, post, files & cookies ****************d*g**/
33:
34: /**
35: * Returns variable provided to the script via URL query ($_GET).
36: * If no key is passed, returns the entire array.
37: * @param string key
38: * @param mixed default value
39: * @return mixed
40: */
41: function getQuery($key = null, $default = null);
42:
43: /**
44: * Returns variable provided to the script via POST method ($_POST).
45: * If no key is passed, returns the entire array.
46: * @param string key
47: * @param mixed default value
48: * @return mixed
49: */
50: function getPost($key = null, $default = null);
51:
52: /**
53: * Returns uploaded file.
54: * @param string key
55: * @return FileUpload|array|null
56: */
57: function getFile($key);
58:
59: /**
60: * Returns uploaded files.
61: * @return array
62: */
63: function getFiles();
64:
65: /**
66: * Returns variable provided to the script via HTTP cookies.
67: * @param string key
68: * @param mixed default value
69: * @return mixed
70: */
71: function getCookie($key, $default = null);
72:
73: /**
74: * Returns variables provided to the script via HTTP cookies.
75: * @return array
76: */
77: function getCookies();
78:
79: /********************* method & headers ****************d*g**/
80:
81: /**
82: * Returns HTTP request method (GET, POST, HEAD, PUT, ...). The method is case-sensitive.
83: * @return string
84: */
85: function getMethod();
86:
87: /**
88: * Checks HTTP request method.
89: * @param string
90: * @return bool
91: */
92: function isMethod($method);
93:
94: /**
95: * Return the value of the HTTP header. Pass the header name as the
96: * plain, HTTP-specified header name (e.g. 'Accept-Encoding').
97: * @param string
98: * @param string|null
99: * @return string|null
100: */
101: function getHeader($header, $default = null);
102:
103: /**
104: * Returns all HTTP headers.
105: * @return array
106: */
107: function getHeaders();
108:
109: /**
110: * Is the request sent via secure channel (https)?
111: * @return bool
112: */
113: function isSecured();
114:
115: /**
116: * Is AJAX request?
117: * @return bool
118: */
119: function isAjax();
120:
121: /**
122: * Returns the IP address of the remote client.
123: * @return string|null
124: */
125: function getRemoteAddress();
126:
127: /**
128: * Returns the host of the remote client.
129: * @return string|null
130: */
131: function getRemoteHost();
132:
133: /**
134: * Returns raw content of HTTP request body.
135: * @return string|null
136: */
137: function getRawBody();
138: }
139: