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