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: * @author David Grudl
15: */
16: interface IRequest
17: {
18: /** HTTP request method */
19: const
20: GET = 'GET',
21: POST = 'POST',
22: HEAD = 'HEAD',
23: PUT = 'PUT',
24: DELETE = 'DELETE';
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 (or more keys)
55: * @return FileUpload|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 mixed
99: * @return mixed
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 is 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: }
140: