PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 4.1.17
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v4.1.17
4.1.19 4.1.18 4.1.17 4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.0.30 4.0.29 4.0.28 4.0.27 4.0.26 4.0.24 4.0.25 4.0.23 4.0.22 4.0.21 4.0.19 4.0.18 4.0.17 4.0.16 1.9.3 All 173 releases
searchpro / BerqWP / vendor / guzzlehttp / guzzle / src / Handler / HeaderProcessor.php

HeaderProcessor.php in BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript 4.1.17, at BerqWP/vendor/guzzlehttp/guzzle/src/Handler/HeaderProcessor.php

43 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace GuzzleHttp\Handler;
4
5 use GuzzleHttp\Utils;
6
7 /**
8 * @internal
9 */
10 final class HeaderProcessor
11 {
12 /**
13 * Returns the HTTP version, status code, reason phrase, and headers.
14 *
15 * @param string[] $headers
16 *
17 * @return array{0:string, 1:int, 2:?string, 3:array}
18 *
19 * @throws \RuntimeException
20 */
21 public static function parseHeaders(array $headers): array
22 {
23 if ($headers === []) {
24 throw new \RuntimeException('Expected a non-empty array of header data');
25 }
26
27 $parts = \explode(' ', \array_shift($headers), 3);
28 $version = \explode('/', $parts[0])[1] ?? null;
29
30 if ($version === null) {
31 throw new \RuntimeException('HTTP version missing from header data');
32 }
33
34 $status = $parts[1] ?? null;
35
36 if ($status === null) {
37 throw new \RuntimeException('HTTP status code missing from header data');
38 }
39
40 return [$version, (int) $status, $parts[2] ?? null, Utils::headersFromLines($headers)];
41 }
42 }
43