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