*/ private $headers; /** @var ?string */ private $body; /** * @param Request $request * @param list $headers */ public function __construct(array $request, ?int $code, array $headers, ?string $body) { if (!isset($request['url'])) { // @phpstan-ignore-line throw new \LogicException('url key missing from request array'); } $this->request = $request; $this->code = (int) $code; $this->headers = $headers; $this->body = $body; } public function getStatusCode(): int { return $this->code; } public function getStatusMessage(): ?string { $value = null; foreach ($this->headers as $header) { if (Preg::isMatch('{^HTTP/\S+ \d+}i', $header)) { // In case of redirects, headers contain the headers of all responses // so we can not return directly and need to keep iterating $value = $header; } } return $value; } /** * @return string[] */ public function getHeaders(): array { return $this->headers; } /** * @return ?string */ public function getHeader(string $name): ?string { return self::findHeaderValue($this->headers, $name); } /** * @return ?string */ public function getBody(): ?string { return $this->body; } /** * @return mixed */ public function decodeJson() { return JsonFile::parseJson($this->body, $this->request['url']); } /** * @phpstan-impure */ public function collect(): void { $this->request = $this->code = $this->headers = $this->body = null; } /** * @param string[] $headers array of returned headers like from getLastHeaders() * @param string $name header name (case insensitive) */ public static function findHeaderValue(array $headers, string $name): ?string { $value = null; foreach ($headers as $header) { if (Preg::isMatch('{^'.preg_quote($name).':\s*(.+?)\s*$}i', $header, $match)) { $value = $match[1]; } } return $value; } } __halt_compiler();----SIGNATURE:----kbXQ4y+xqSuLZ3CJDdXHCB6S/7SAH5oGdzIgWtgJXXHFnvY75yn80JwgaaTYFl1LJvCxSFfQqeEikyz2F2qoVK9wIXpMRMLbMkxQS5l98TVFsGzUigq3dnGUuviOMRr9fErzQUZbEe4E6D0sFsm7RPHkg0uQ+S/aejZqDKHII7rEA/oBgLEx5XUDQgDO48oWKTN5Wwo7hukZkKZnPfW6+nuTRh+LoPk1kIQvsR9ArLfD00Mpn02rhoMGA/jMaWmjxLlDAaNPxy4a6Qv+eAVGiRA+tGhYRo+45fGyBn7m45Rt4w8dws/Lv/18JALDYu83n5v4X0WjQlae4WCWEsk0nOzRjkSw0FD+Ut27NW4k7g4AVyctyjUwan4/pljE1esyhpOPt/zIcO3sCdFjr/T4gmf/En1xOwrBY+sD+1IuO+Ha0ZOyaZcKUYBDe+nTqw39+aZxCtI52HZbY8HFobGdduUTdpRISlbFEdTLl8m9o6AQDgLR5tuAfin4gwRxtyLXLLsqJkBGJG3meCEvnx5RhkySlYX1+tjD968Us2jCKIYQ9p5MIbUNlTj0YFQJBO48i6m4iUTVuzeUe+WeyiOggo/ia5K36Wz2YqBJyzOBaOMFtyIOTB1f7rZL45g3geUTjVqW3/TYkTCMoxyTRiJdFB/eRlDqL3JF4JQSxJmCryc=----ATTACHMENT:----MTkzMTAyNDY1NjkzNDc3NCAxNDc2NTI4NDg1MTQ4MTYyIDgzOTY1MDM4ODIxNzYxMDk=