-
-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathIRequest.php
More file actions
131 lines (103 loc) · 3.11 KB
/
Copy pathIRequest.php
File metadata and controls
131 lines (103 loc) · 3.11 KB
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
<?php declare(strict_types=1);
/**
* This file is part of the Nette Framework (https://nette.org)
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
*/
namespace Nette\Http;
/**
* HTTP request contract providing access to URL, headers, cookies, uploaded files, and body.
* @method ?UrlImmutable getReferer() Returns the referrer URL.
* @method bool isFrom(FetchSite|list<FetchSite> $site, FetchDest|list<FetchDest>|null $dest = null, ?bool $user = null)
*/
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 the request URL.
*/
function getUrl(): UrlScript;
/********************* query, post, files & cookies ****************d*g**/
/**
* Returns a URL query parameter, or all parameters as an array if no key is given.
*/
function getQuery(?string $key = null): mixed;
/**
* Returns a POST parameter, or all POST parameters as an array if no key is given.
*/
function getPost(?string $key = null): mixed;
/**
* Returns the uploaded file for the given key, or null if not present.
* Accepts a string key or an array of keys for nested file structures (e.g. ['form', 'avatar']).
*/
function getFile(string $key): ?FileUpload;
/**
* Returns the tree of uploaded files, with each leaf being a FileUpload instance.
* @return mixed[]
*/
function getFiles(): array;
/**
* Returns a cookie value, or null if it does not exist.
*/
function getCookie(string $key): mixed;
/**
* Returns all cookies.
* @return array<string, string>
*/
function getCookies(): array;
/********************* method & headers ****************d*g**/
/**
* Returns the HTTP request method (GET, POST, HEAD, PUT, ...).
*/
function getMethod(): string;
/**
* Checks the HTTP request method. The comparison is case-insensitive.
*/
function isMethod(string $method): bool;
/**
* Returns the value of an HTTP header, or null if it does not exist. The name is case-insensitive.
*/
function getHeader(string $header): ?string;
/**
* Returns all HTTP headers.
* @return array<string, string>
*/
function getHeaders(): array;
/**
* Checks whether the request was sent via a secure channel (HTTPS).
*/
function isSecured(): bool;
/**
* Checks whether the request was made via AJAX (X-Requested-With: XMLHttpRequest).
*/
function isAjax(): bool;
/**
* Returns the IP address of the remote client.
*/
function getRemoteAddress(): ?string;
/**
* Returns raw content of HTTP request body.
*/
function getRawBody(): ?string;
}