-
-
Notifications
You must be signed in to change notification settings - Fork 89
/
IRequest.php
137 lines (107 loc) 路 2.88 KB
/
IRequest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
/**
* This file is part of the Nette Framework (https://nette.org)
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
*/
declare(strict_types=1);
namespace Nette\Http;
/**
* HTTP request provides access scheme for request sent via HTTP.
* @method UrlImmutable|null getReferer() Returns referrer.
* @method bool isSameSite() Is the request sent from the same origin?
*/
interface IRequest
{
/** HTTP request method */
public const
Get = 'GET',
Post = 'POST',
Head = 'HEAD',
Put = 'PUT',
Delete = 'DELETE',
Patch = 'PATCH',
Options = 'OPTIONS';
/** @deprecated use IRequest::Get */
public const GET = self::Get;
/** @deprecated use IRequest::Post */
public const POST = self::Post;
/** @deprecated use IRequest::Head */
public const HEAD = self::Head;
/** @deprecated use IRequest::Put */
public const PUT = self::Put;
/** @deprecated use IRequest::Delete */
public const DELETE = self::Delete;
/** @deprecated use IRequest::Patch */
public const PATCH = self::Patch;
/** @deprecated use IRequest::Options */
public const OPTIONS = self::Options;
/**
* Returns URL object.
*/
function getUrl(): UrlScript;
/********************* query, post, files & cookies ****************d*g**/
/**
* Returns variable provided to the script via URL query ($_GET).
* If no key is passed, returns the entire array.
*/
function getQuery(?string $key = null): mixed;
/**
* Returns variable provided to the script via POST method ($_POST).
* If no key is passed, returns the entire array.
*/
function getPost(?string $key = null): mixed;
/**
* Returns uploaded file.
*/
function getFile(string $key): ?FileUpload;
/**
* Returns uploaded files.
*/
function getFiles(): array;
/**
* Returns variable provided to the script via HTTP cookies.
*/
function getCookie(string $key): mixed;
/**
* Returns variables provided to the script via HTTP cookies.
*/
function getCookies(): array;
/********************* method & headers ****************d*g**/
/**
* Returns HTTP request method (GET, POST, HEAD, PUT, ...). The method is case-sensitive.
*/
function getMethod(): string;
/**
* Checks HTTP request method.
*/
function isMethod(string $method): bool;
/**
* Return the value of the HTTP header. Pass the header name as the
* plain, HTTP-specified header name (e.g. 'Accept-Encoding').
*/
function getHeader(string $header): ?string;
/**
* Returns all HTTP headers.
*/
function getHeaders(): array;
/**
* Is the request sent via secure channel (https)?
*/
function isSecured(): bool;
/**
* Is AJAX request?
*/
function isAjax(): bool;
/**
* Returns the IP address of the remote client.
*/
function getRemoteAddress(): ?string;
/**
* Returns the host of the remote client.
*/
function getRemoteHost(): ?string;
/**
* Returns raw content of HTTP request body.
*/
function getRawBody(): ?string;
}