| 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 |
declare (strict_types=1); |
| 8 |
namespace Packetery\Nette\Http; |
| 9 |
|
| 10 |
/** |
| 11 |
* HTTP request provides access scheme for request sent via HTTP. |
| 12 |
* @method UrlImmutable|null getReferer() Returns referrer. |
| 13 |
* @method bool isSameSite() Is the request sent from the same origin? |
| 14 |
*/ |
| 15 |
interface IRequest |
| 16 |
{ |
| 17 |
/** HTTP request method */ |
| 18 |
public const Get = 'GET', Post = 'POST', Head = 'HEAD', Put = 'PUT', Delete = 'DELETE', Patch = 'PATCH', Options = 'OPTIONS'; |
| 19 |
/** @deprecated use IRequest::Get */ |
| 20 |
public const GET = self::Get; |
| 21 |
/** @deprecated use IRequest::Post */ |
| 22 |
public const POST = self::Post; |
| 23 |
/** @deprecated use IRequest::Head */ |
| 24 |
public const HEAD = self::Head; |
| 25 |
/** @deprecated use IRequest::Put */ |
| 26 |
public const PUT = self::Put; |
| 27 |
/** @deprecated use IRequest::Delete */ |
| 28 |
public const DELETE = self::Delete; |
| 29 |
/** @deprecated use IRequest::Patch */ |
| 30 |
public const PATCH = self::Patch; |
| 31 |
/** @deprecated use IRequest::Options */ |
| 32 |
public const OPTIONS = self::Options; |
| 33 |
/** |
| 34 |
* Returns URL object. |
| 35 |
*/ |
| 36 |
function getUrl() : UrlScript; |
| 37 |
/********************* query, post, files & cookies ****************d*g**/ |
| 38 |
/** |
| 39 |
* Returns variable provided to the script via URL query ($_GET). |
| 40 |
* If no key is passed, returns the entire array. |
| 41 |
* @return mixed |
| 42 |
*/ |
| 43 |
function getQuery(?string $key = null); |
| 44 |
/** |
| 45 |
* Returns variable provided to the script via POST method ($_POST). |
| 46 |
* If no key is passed, returns the entire array. |
| 47 |
* @return mixed |
| 48 |
*/ |
| 49 |
function getPost(?string $key = null); |
| 50 |
/** |
| 51 |
* Returns uploaded file. |
| 52 |
* @return FileUpload|array|null |
| 53 |
*/ |
| 54 |
function getFile(string $key); |
| 55 |
/** |
| 56 |
* Returns uploaded files. |
| 57 |
*/ |
| 58 |
function getFiles() : array; |
| 59 |
/** |
| 60 |
* Returns variable provided to the script via HTTP cookies. |
| 61 |
* @return mixed |
| 62 |
*/ |
| 63 |
function getCookie(string $key); |
| 64 |
/** |
| 65 |
* Returns variables provided to the script via HTTP cookies. |
| 66 |
*/ |
| 67 |
function getCookies() : array; |
| 68 |
/********************* method & headers ****************d*g**/ |
| 69 |
/** |
| 70 |
* Returns HTTP request method (GET, POST, HEAD, PUT, ...). The method is case-sensitive. |
| 71 |
*/ |
| 72 |
function getMethod() : string; |
| 73 |
/** |
| 74 |
* Checks HTTP request method. |
| 75 |
*/ |
| 76 |
function isMethod(string $method) : bool; |
| 77 |
/** |
| 78 |
* Return the value of the HTTP header. Pass the header name as the |
| 79 |
* plain, HTTP-specified header name (e.g. 'Accept-Encoding'). |
| 80 |
*/ |
| 81 |
function getHeader(string $header) : ?string; |
| 82 |
/** |
| 83 |
* Returns all HTTP headers. |
| 84 |
*/ |
| 85 |
function getHeaders() : array; |
| 86 |
/** |
| 87 |
* Is the request sent via secure channel (https)? |
| 88 |
*/ |
| 89 |
function isSecured() : bool; |
| 90 |
/** |
| 91 |
* Is AJAX request? |
| 92 |
*/ |
| 93 |
function isAjax() : bool; |
| 94 |
/** |
| 95 |
* Returns the IP address of the remote client. |
| 96 |
*/ |
| 97 |
function getRemoteAddress() : ?string; |
| 98 |
/** |
| 99 |
* Returns the host of the remote client. |
| 100 |
*/ |
| 101 |
function getRemoteHost() : ?string; |
| 102 |
/** |
| 103 |
* Returns raw content of HTTP request body. |
| 104 |
*/ |
| 105 |
function getRawBody() : ?string; |
| 106 |
} |
| 107 |
|