@@ -64,227 +64,227 @@ |
||
| 64 | 64 | * @since 6.0.0 |
| 65 | 65 | */ |
| 66 | 66 | interface IRequest { |
| 67 | - /** |
|
| 68 | - * @since 9.1.0 |
|
| 69 | - */ |
|
| 70 | - const USER_AGENT_CLIENT_ANDROID = '/^Mozilla\/5\.0 \(Android\) (ownCloud|Nextcloud)\-android.*$/'; |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * @since 13.0.0 |
|
| 74 | - */ |
|
| 75 | - const USER_AGENT_TALK_ANDROID = '/^Mozilla\/5\.0 \(Android\) Nextcloud\-Talk v.*$/'; |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * @since 9.1.0 |
|
| 79 | - */ |
|
| 80 | - const USER_AGENT_CLIENT_DESKTOP = '/^Mozilla\/5\.0 \([A-Za-z ]+\) (mirall|csyncoC)\/.*$/'; |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * @since 9.1.0 |
|
| 84 | - */ |
|
| 85 | - const USER_AGENT_CLIENT_IOS = '/^Mozilla\/5\.0 \(iOS\) (ownCloud|Nextcloud)\-iOS.*$/'; |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * @since 13.0.0 |
|
| 89 | - */ |
|
| 90 | - const USER_AGENT_TALK_IOS = '/^Mozilla\/5\.0 \(iOS\) Nextcloud\-Talk v.*$/'; |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * @param string $name |
|
| 94 | - * |
|
| 95 | - * @return string |
|
| 96 | - * @since 6.0.0 |
|
| 97 | - */ |
|
| 98 | - public function getHeader($name); |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * Lets you access post and get parameters by the index |
|
| 102 | - * In case of json requests the encoded json body is accessed |
|
| 103 | - * |
|
| 104 | - * @param string $key the key which you want to access in the URL Parameter |
|
| 105 | - * placeholder, $_POST or $_GET array. |
|
| 106 | - * The priority how they're returned is the following: |
|
| 107 | - * 1. URL parameters |
|
| 108 | - * 2. POST parameters |
|
| 109 | - * 3. GET parameters |
|
| 110 | - * @param mixed $default If the key is not found, this value will be returned |
|
| 111 | - * @return mixed the content of the array |
|
| 112 | - * @since 6.0.0 |
|
| 113 | - */ |
|
| 114 | - public function getParam($key, $default = null); |
|
| 115 | - |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * Returns all params that were received, be it from the request |
|
| 119 | - * |
|
| 120 | - * (as GET or POST) or through the URL by the route |
|
| 121 | - * |
|
| 122 | - * @return array the array with all parameters |
|
| 123 | - * @since 6.0.0 |
|
| 124 | - */ |
|
| 125 | - public function getParams(); |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * Returns the method of the request |
|
| 129 | - * |
|
| 130 | - * @return string the method of the request (POST, GET, etc) |
|
| 131 | - * @since 6.0.0 |
|
| 132 | - */ |
|
| 133 | - public function getMethod(); |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Shortcut for accessing an uploaded file through the $_FILES array |
|
| 137 | - * |
|
| 138 | - * @param string $key the key that will be taken from the $_FILES array |
|
| 139 | - * @return array the file in the $_FILES element |
|
| 140 | - * @since 6.0.0 |
|
| 141 | - */ |
|
| 142 | - public function getUploadedFile($key); |
|
| 143 | - |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * Shortcut for getting env variables |
|
| 147 | - * |
|
| 148 | - * @param string $key the key that will be taken from the $_ENV array |
|
| 149 | - * @return array the value in the $_ENV element |
|
| 150 | - * @since 6.0.0 |
|
| 151 | - */ |
|
| 152 | - public function getEnv($key); |
|
| 153 | - |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Shortcut for getting cookie variables |
|
| 157 | - * |
|
| 158 | - * @param string $key the key that will be taken from the $_COOKIE array |
|
| 159 | - * @return string|null the value in the $_COOKIE element |
|
| 160 | - * @since 6.0.0 |
|
| 161 | - */ |
|
| 162 | - public function getCookie($key); |
|
| 163 | - |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * Checks if the CSRF check was correct |
|
| 167 | - * |
|
| 168 | - * @return bool true if CSRF check passed |
|
| 169 | - * @since 6.0.0 |
|
| 170 | - */ |
|
| 171 | - public function passesCSRFCheck(); |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * Checks if the strict cookie has been sent with the request if the request |
|
| 175 | - * is including any cookies. |
|
| 176 | - * |
|
| 177 | - * @return bool |
|
| 178 | - * @since 9.0.0 |
|
| 179 | - */ |
|
| 180 | - public function passesStrictCookieCheck(); |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * Checks if the lax cookie has been sent with the request if the request |
|
| 184 | - * is including any cookies. |
|
| 185 | - * |
|
| 186 | - * @return bool |
|
| 187 | - * @since 9.0.0 |
|
| 188 | - */ |
|
| 189 | - public function passesLaxCookieCheck(); |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * Returns an ID for the request, value is not guaranteed to be unique and is mostly meant for logging |
|
| 193 | - * If `mod_unique_id` is installed this value will be taken. |
|
| 194 | - * |
|
| 195 | - * @return string |
|
| 196 | - * @since 8.1.0 |
|
| 197 | - */ |
|
| 198 | - public function getId(); |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * Returns the remote address, if the connection came from a trusted proxy |
|
| 202 | - * and `forwarded_for_headers` has been configured then the IP address |
|
| 203 | - * specified in this header will be returned instead. |
|
| 204 | - * Do always use this instead of $_SERVER['REMOTE_ADDR'] |
|
| 205 | - * |
|
| 206 | - * @return string IP address |
|
| 207 | - * @since 8.1.0 |
|
| 208 | - */ |
|
| 209 | - public function getRemoteAddress(); |
|
| 210 | - |
|
| 211 | - /** |
|
| 212 | - * Returns the server protocol. It respects reverse proxy servers and load |
|
| 213 | - * balancers. |
|
| 214 | - * |
|
| 215 | - * @return string Server protocol (http or https) |
|
| 216 | - * @since 8.1.0 |
|
| 217 | - */ |
|
| 218 | - public function getServerProtocol(); |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * Returns the used HTTP protocol. |
|
| 222 | - * |
|
| 223 | - * @return string HTTP protocol. HTTP/2, HTTP/1.1 or HTTP/1.0. |
|
| 224 | - * @since 8.2.0 |
|
| 225 | - */ |
|
| 226 | - public function getHttpProtocol(); |
|
| 227 | - |
|
| 228 | - /** |
|
| 229 | - * Returns the request uri, even if the website uses one or more |
|
| 230 | - * reverse proxies |
|
| 231 | - * |
|
| 232 | - * @return string |
|
| 233 | - * @since 8.1.0 |
|
| 234 | - */ |
|
| 235 | - public function getRequestUri(); |
|
| 236 | - |
|
| 237 | - /** |
|
| 238 | - * Get raw PathInfo from request (not urldecoded) |
|
| 239 | - * |
|
| 240 | - * @throws \Exception |
|
| 241 | - * @return string Path info |
|
| 242 | - * @since 8.1.0 |
|
| 243 | - */ |
|
| 244 | - public function getRawPathInfo(); |
|
| 245 | - |
|
| 246 | - /** |
|
| 247 | - * Get PathInfo from request |
|
| 248 | - * |
|
| 249 | - * @throws \Exception |
|
| 250 | - * @return string|false Path info or false when not found |
|
| 251 | - * @since 8.1.0 |
|
| 252 | - */ |
|
| 253 | - public function getPathInfo(); |
|
| 254 | - |
|
| 255 | - /** |
|
| 256 | - * Returns the script name, even if the website uses one or more |
|
| 257 | - * reverse proxies |
|
| 258 | - * |
|
| 259 | - * @return string the script name |
|
| 260 | - * @since 8.1.0 |
|
| 261 | - */ |
|
| 262 | - public function getScriptName(); |
|
| 263 | - |
|
| 264 | - /** |
|
| 265 | - * Checks whether the user agent matches a given regex |
|
| 266 | - * |
|
| 267 | - * @param array $agent array of agent names |
|
| 268 | - * @return bool true if at least one of the given agent matches, false otherwise |
|
| 269 | - * @since 8.1.0 |
|
| 270 | - */ |
|
| 271 | - public function isUserAgent(array $agent); |
|
| 272 | - |
|
| 273 | - /** |
|
| 274 | - * Returns the unverified server host from the headers without checking |
|
| 275 | - * whether it is a trusted domain |
|
| 276 | - * |
|
| 277 | - * @return string Server host |
|
| 278 | - * @since 8.1.0 |
|
| 279 | - */ |
|
| 280 | - public function getInsecureServerHost(); |
|
| 281 | - |
|
| 282 | - /** |
|
| 283 | - * Returns the server host from the headers, or the first configured |
|
| 284 | - * trusted domain if the host isn't in the trusted list |
|
| 285 | - * |
|
| 286 | - * @return string Server host |
|
| 287 | - * @since 8.1.0 |
|
| 288 | - */ |
|
| 289 | - public function getServerHost(); |
|
| 67 | + /** |
|
| 68 | + * @since 9.1.0 |
|
| 69 | + */ |
|
| 70 | + const USER_AGENT_CLIENT_ANDROID = '/^Mozilla\/5\.0 \(Android\) (ownCloud|Nextcloud)\-android.*$/'; |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * @since 13.0.0 |
|
| 74 | + */ |
|
| 75 | + const USER_AGENT_TALK_ANDROID = '/^Mozilla\/5\.0 \(Android\) Nextcloud\-Talk v.*$/'; |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * @since 9.1.0 |
|
| 79 | + */ |
|
| 80 | + const USER_AGENT_CLIENT_DESKTOP = '/^Mozilla\/5\.0 \([A-Za-z ]+\) (mirall|csyncoC)\/.*$/'; |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * @since 9.1.0 |
|
| 84 | + */ |
|
| 85 | + const USER_AGENT_CLIENT_IOS = '/^Mozilla\/5\.0 \(iOS\) (ownCloud|Nextcloud)\-iOS.*$/'; |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * @since 13.0.0 |
|
| 89 | + */ |
|
| 90 | + const USER_AGENT_TALK_IOS = '/^Mozilla\/5\.0 \(iOS\) Nextcloud\-Talk v.*$/'; |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * @param string $name |
|
| 94 | + * |
|
| 95 | + * @return string |
|
| 96 | + * @since 6.0.0 |
|
| 97 | + */ |
|
| 98 | + public function getHeader($name); |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * Lets you access post and get parameters by the index |
|
| 102 | + * In case of json requests the encoded json body is accessed |
|
| 103 | + * |
|
| 104 | + * @param string $key the key which you want to access in the URL Parameter |
|
| 105 | + * placeholder, $_POST or $_GET array. |
|
| 106 | + * The priority how they're returned is the following: |
|
| 107 | + * 1. URL parameters |
|
| 108 | + * 2. POST parameters |
|
| 109 | + * 3. GET parameters |
|
| 110 | + * @param mixed $default If the key is not found, this value will be returned |
|
| 111 | + * @return mixed the content of the array |
|
| 112 | + * @since 6.0.0 |
|
| 113 | + */ |
|
| 114 | + public function getParam($key, $default = null); |
|
| 115 | + |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * Returns all params that were received, be it from the request |
|
| 119 | + * |
|
| 120 | + * (as GET or POST) or through the URL by the route |
|
| 121 | + * |
|
| 122 | + * @return array the array with all parameters |
|
| 123 | + * @since 6.0.0 |
|
| 124 | + */ |
|
| 125 | + public function getParams(); |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * Returns the method of the request |
|
| 129 | + * |
|
| 130 | + * @return string the method of the request (POST, GET, etc) |
|
| 131 | + * @since 6.0.0 |
|
| 132 | + */ |
|
| 133 | + public function getMethod(); |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Shortcut for accessing an uploaded file through the $_FILES array |
|
| 137 | + * |
|
| 138 | + * @param string $key the key that will be taken from the $_FILES array |
|
| 139 | + * @return array the file in the $_FILES element |
|
| 140 | + * @since 6.0.0 |
|
| 141 | + */ |
|
| 142 | + public function getUploadedFile($key); |
|
| 143 | + |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * Shortcut for getting env variables |
|
| 147 | + * |
|
| 148 | + * @param string $key the key that will be taken from the $_ENV array |
|
| 149 | + * @return array the value in the $_ENV element |
|
| 150 | + * @since 6.0.0 |
|
| 151 | + */ |
|
| 152 | + public function getEnv($key); |
|
| 153 | + |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Shortcut for getting cookie variables |
|
| 157 | + * |
|
| 158 | + * @param string $key the key that will be taken from the $_COOKIE array |
|
| 159 | + * @return string|null the value in the $_COOKIE element |
|
| 160 | + * @since 6.0.0 |
|
| 161 | + */ |
|
| 162 | + public function getCookie($key); |
|
| 163 | + |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * Checks if the CSRF check was correct |
|
| 167 | + * |
|
| 168 | + * @return bool true if CSRF check passed |
|
| 169 | + * @since 6.0.0 |
|
| 170 | + */ |
|
| 171 | + public function passesCSRFCheck(); |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * Checks if the strict cookie has been sent with the request if the request |
|
| 175 | + * is including any cookies. |
|
| 176 | + * |
|
| 177 | + * @return bool |
|
| 178 | + * @since 9.0.0 |
|
| 179 | + */ |
|
| 180 | + public function passesStrictCookieCheck(); |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * Checks if the lax cookie has been sent with the request if the request |
|
| 184 | + * is including any cookies. |
|
| 185 | + * |
|
| 186 | + * @return bool |
|
| 187 | + * @since 9.0.0 |
|
| 188 | + */ |
|
| 189 | + public function passesLaxCookieCheck(); |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * Returns an ID for the request, value is not guaranteed to be unique and is mostly meant for logging |
|
| 193 | + * If `mod_unique_id` is installed this value will be taken. |
|
| 194 | + * |
|
| 195 | + * @return string |
|
| 196 | + * @since 8.1.0 |
|
| 197 | + */ |
|
| 198 | + public function getId(); |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * Returns the remote address, if the connection came from a trusted proxy |
|
| 202 | + * and `forwarded_for_headers` has been configured then the IP address |
|
| 203 | + * specified in this header will be returned instead. |
|
| 204 | + * Do always use this instead of $_SERVER['REMOTE_ADDR'] |
|
| 205 | + * |
|
| 206 | + * @return string IP address |
|
| 207 | + * @since 8.1.0 |
|
| 208 | + */ |
|
| 209 | + public function getRemoteAddress(); |
|
| 210 | + |
|
| 211 | + /** |
|
| 212 | + * Returns the server protocol. It respects reverse proxy servers and load |
|
| 213 | + * balancers. |
|
| 214 | + * |
|
| 215 | + * @return string Server protocol (http or https) |
|
| 216 | + * @since 8.1.0 |
|
| 217 | + */ |
|
| 218 | + public function getServerProtocol(); |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * Returns the used HTTP protocol. |
|
| 222 | + * |
|
| 223 | + * @return string HTTP protocol. HTTP/2, HTTP/1.1 or HTTP/1.0. |
|
| 224 | + * @since 8.2.0 |
|
| 225 | + */ |
|
| 226 | + public function getHttpProtocol(); |
|
| 227 | + |
|
| 228 | + /** |
|
| 229 | + * Returns the request uri, even if the website uses one or more |
|
| 230 | + * reverse proxies |
|
| 231 | + * |
|
| 232 | + * @return string |
|
| 233 | + * @since 8.1.0 |
|
| 234 | + */ |
|
| 235 | + public function getRequestUri(); |
|
| 236 | + |
|
| 237 | + /** |
|
| 238 | + * Get raw PathInfo from request (not urldecoded) |
|
| 239 | + * |
|
| 240 | + * @throws \Exception |
|
| 241 | + * @return string Path info |
|
| 242 | + * @since 8.1.0 |
|
| 243 | + */ |
|
| 244 | + public function getRawPathInfo(); |
|
| 245 | + |
|
| 246 | + /** |
|
| 247 | + * Get PathInfo from request |
|
| 248 | + * |
|
| 249 | + * @throws \Exception |
|
| 250 | + * @return string|false Path info or false when not found |
|
| 251 | + * @since 8.1.0 |
|
| 252 | + */ |
|
| 253 | + public function getPathInfo(); |
|
| 254 | + |
|
| 255 | + /** |
|
| 256 | + * Returns the script name, even if the website uses one or more |
|
| 257 | + * reverse proxies |
|
| 258 | + * |
|
| 259 | + * @return string the script name |
|
| 260 | + * @since 8.1.0 |
|
| 261 | + */ |
|
| 262 | + public function getScriptName(); |
|
| 263 | + |
|
| 264 | + /** |
|
| 265 | + * Checks whether the user agent matches a given regex |
|
| 266 | + * |
|
| 267 | + * @param array $agent array of agent names |
|
| 268 | + * @return bool true if at least one of the given agent matches, false otherwise |
|
| 269 | + * @since 8.1.0 |
|
| 270 | + */ |
|
| 271 | + public function isUserAgent(array $agent); |
|
| 272 | + |
|
| 273 | + /** |
|
| 274 | + * Returns the unverified server host from the headers without checking |
|
| 275 | + * whether it is a trusted domain |
|
| 276 | + * |
|
| 277 | + * @return string Server host |
|
| 278 | + * @since 8.1.0 |
|
| 279 | + */ |
|
| 280 | + public function getInsecureServerHost(); |
|
| 281 | + |
|
| 282 | + /** |
|
| 283 | + * Returns the server host from the headers, or the first configured |
|
| 284 | + * trusted domain if the host isn't in the trusted list |
|
| 285 | + * |
|
| 286 | + * @return string Server host |
|
| 287 | + * @since 8.1.0 |
|
| 288 | + */ |
|
| 289 | + public function getServerHost(); |
|
| 290 | 290 | } |