Repository navigation
Expand file tree
/
Copy pathPHPServerAdapter.php
More file actions
132 lines (120 loc) · 3.16 KB
/
Copy pathPHPServerAdapter.php
File metadata and controls
132 lines (120 loc) · 3.16 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
132
<?php
declare(strict_types=1);
namespace Arcanum\Hyper;
/**
* PHP Server Adapter
* ------------------
*
* This class is a wrapper around PHP's built-in functions for interacting with
* headers, output buffers, and the request/response cycle.
*
* Since these are just simple function wrappers, we don't need to test them.
* @codeCoverageIgnore
*/
class PHPServerAdapter implements ServerAdapter
{
/**
* @return array<string,string> The HTTP header key/value pairs.
*/
public function getallheaders(): array
{
return \getallheaders();
}
/**
* Checks if or where headers have been sent.
*
* You can't add any more header lines using the header() function once the
* header block has already been sent. Using this function you can at least
* prevent getting HTTP header related error messages.
*/
public function headersSent(string|null &$file = null, int|null &$line = null): bool
{
return \headers_sent($file, $line);
}
/**
* Send a raw HTTP header.
*
* Remember that header() must be called before any actual output is sent
*/
public function header(string $header, bool $replace = true, int $responseCode = 0): void
{
\header($header, $replace, $responseCode);
}
/**
* Echo content to the client.
*/
public function echo(string $content): void
{
echo $content;
}
/**
* Should call fastcgi_finish_request() if possible, and should return
* false if fastcgi_finish_request() is not available.
*/
public function fastCGIFinishRequest(): bool
{
if (\function_exists('fastcgi_finish_request')) {
\fastcgi_finish_request();
return true;
}
return false;
}
/**
* Should call litespeed_finish_request() if possible, and should return
* false if litespeed_finish_request() is not available.
*/
public function litespeedFinishRequest(): bool
{
$lightspeedFinishRequest = 'litespeed_finish_request';
if (\function_exists($lightspeedFinishRequest)) {
$lightspeedFinishRequest();
return true;
}
return false;
}
/**
* Flush the system write buffers.
*/
public function flush(): void
{
\flush();
}
/**
* Get status information on either the top level output buffer or all
* active output buffer levels if $fullStatus is true.
*
* @return array{
* level: int,
* type?: 0|1,
* status?: int,
* name?: string,
* del?: int
* }|(array<int, array{
* type?: 0|1,
* status?: int,
* name?: string,
* del?: int,
* chunk_size?: int,
* size?: int,
* block_size?: int,
* }>)
*/
public function obGetStatus(bool $fullStatus = false): array
{
return \ob_get_status($fullStatus);
}
/**
* Call ob_end_flush()
*/
public function obEndFlush(): bool
{
return \ob_end_flush();
}
/**
* Call ob_end_clean()
*/
public function obEndClean(): bool
{
return \ob_end_clean();
}
}