| 1 |
<?php |
| 2 |
|
| 3 |
declare (strict_types=1); |
| 4 |
namespace WCPOS\Vendor\Sentry\Util; |
| 5 |
|
| 6 |
use WCPOS\Vendor\Sentry\Client; |
| 7 |
use WCPOS\Vendor\Sentry\Dsn; |
| 8 |
/** |
| 9 |
* @internal |
| 10 |
*/ |
| 11 |
final class Http |
| 12 |
{ |
| 13 |
public static function getSentryAuthHeader(Dsn $dsn, string $sdkIdentifier, string $sdkVersion) : string |
| 14 |
{ |
| 15 |
$authHeader = ['sentry_version=' . Client::PROTOCOL_VERSION, 'sentry_client=' . $sdkIdentifier . '/' . $sdkVersion, 'sentry_key=' . $dsn->getPublicKey()]; |
| 16 |
return 'Sentry ' . \implode(', ', $authHeader); |
| 17 |
} |
| 18 |
/** |
| 19 |
* @return string[] |
| 20 |
*/ |
| 21 |
public static function getRequestHeaders(Dsn $dsn, string $sdkIdentifier, string $sdkVersion) : array |
| 22 |
{ |
| 23 |
return ['Content-Type: application/x-sentry-envelope', 'X-Sentry-Auth: ' . self::getSentryAuthHeader($dsn, $sdkIdentifier, $sdkVersion)]; |
| 24 |
} |
| 25 |
/** |
| 26 |
* @param string[][] $headers |
| 27 |
* |
| 28 |
* @param-out string[][] $headers |
| 29 |
*/ |
| 30 |
public static function parseResponseHeaders(string $headerLine, array &$headers) : int |
| 31 |
{ |
| 32 |
if (\strpos($headerLine, ':') === \false) { |
| 33 |
return \strlen($headerLine); |
| 34 |
} |
| 35 |
[$name, $value] = \explode(':', \trim($headerLine), 2); |
| 36 |
$name = \trim($name); |
| 37 |
$value = \trim($value); |
| 38 |
if (isset($headers[$name])) { |
| 39 |
$headers[$name][] = $value; |
| 40 |
} else { |
| 41 |
$headers[$name] = (array) $value; |
| 42 |
} |
| 43 |
return \strlen($headerLine); |
| 44 |
} |
| 45 |
} |
| 46 |
|