PluginProbe
Media Cloud Sync / 1.3.11
Media Cloud Sync v1.3.11
1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 All 34 releases
media-cloud-sync / includes / sdk / s3 / GuzzleHttp / Handler / HeaderProcessor.php

HeaderProcessor.php in Media Cloud Sync 1.3.11, at includes/sdk/s3/GuzzleHttp/Handler/HeaderProcessor.php

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