ci4

Форк
0
/
MessageInterface.php 
145 строк · 3.7 Кб
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of CodeIgniter 4 framework.
7
 *
8
 * (c) CodeIgniter Foundation <admin@codeigniter.com>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace CodeIgniter\HTTP;
15

16
use CodeIgniter\HTTP\Exceptions\HTTPException;
17

18
/**
19
 * Expected behavior of an HTTP message
20
 */
21
interface MessageInterface
22
{
23
    /**
24
     * Retrieves the HTTP protocol version as a string.
25
     *
26
     * The string MUST contain only the HTTP version number (e.g., "1.1", "1.0").
27
     *
28
     * @return string HTTP protocol version.
29
     */
30
    public function getProtocolVersion(): string;
31

32
    /**
33
     * Sets the body of the current message.
34
     *
35
     * @param string $data
36
     *
37
     * @return $this
38
     */
39
    public function setBody($data);
40

41
    /**
42
     * Gets the body of the message.
43
     *
44
     * @return string|null
45
     *
46
     * @TODO Incompatible return type with PSR-7
47
     */
48
    public function getBody();
49

50
    /**
51
     * Appends data to the body of the current message.
52
     *
53
     * @param string $data
54
     *
55
     * @return $this
56
     */
57
    public function appendBody($data);
58

59
    /**
60
     * Populates the $headers array with any headers the server knows about.
61
     */
62
    public function populateHeaders(): void;
63

64
    /**
65
     * Returns an array containing all Headers.
66
     *
67
     * @return array<string, Header|list<Header>> An array of the Header objects
68
     */
69
    public function headers(): array;
70

71
    /**
72
     * Checks if a header exists by the given case-insensitive name.
73
     *
74
     * @param string $name Case-insensitive header field name.
75
     *
76
     * @return bool Returns true if any header names match the given header
77
     *              name using a case-insensitive string comparison. Returns false if
78
     *              no matching header name is found in the message.
79
     */
80
    public function hasHeader(string $name): bool;
81

82
    /**
83
     * Returns a single Header object. If multiple headers with the same
84
     * name exist, then will return an array of header objects.
85
     *
86
     * @param string $name
87
     *
88
     * @return Header|list<Header>|null
89
     */
90
    public function header($name);
91

92
    /**
93
     * Retrieves a comma-separated string of the values for a single header.
94
     *
95
     * This method returns all of the header values of the given
96
     * case-insensitive header name as a string concatenated together using
97
     * a comma.
98
     *
99
     * NOTE: Not all header values may be appropriately represented using
100
     * comma concatenation. For such headers, use getHeader() instead
101
     * and supply your own delimiter when concatenating.
102
     */
103
    public function getHeaderLine(string $name): string;
104

105
    /**
106
     * Sets a header and it's value.
107
     *
108
     * @param array|string|null $value
109
     *
110
     * @return $this
111
     */
112
    public function setHeader(string $name, $value);
113

114
    /**
115
     * Removes a header from the list of headers we track.
116
     *
117
     * @return $this
118
     */
119
    public function removeHeader(string $name);
120

121
    /**
122
     * Adds an additional header value to any headers that accept
123
     * multiple values (i.e. are an array or implement ArrayAccess)
124
     *
125
     * @return $this
126
     */
127
    public function appendHeader(string $name, ?string $value);
128

129
    /**
130
     * Adds an additional header value to any headers that accept
131
     * multiple values (i.e. are an array or implement ArrayAccess)
132
     *
133
     * @return $this
134
     */
135
    public function prependHeader(string $name, string $value);
136

137
    /**
138
     * Sets the HTTP protocol version.
139
     *
140
     * @return $this
141
     *
142
     * @throws HTTPException For invalid protocols
143
     */
144
    public function setProtocolVersion(string $version);
145
}
146

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.