public static function fromArray(array $response)
{
$body = isset($response['body']) ? $response['body'] : null;
$gzip = isset($response['headers']['Content-Type']) && strpos($response['headers']['Content-Type'], 'application/x-gzip') !== false;
$binary = isset($response['headers']['Content-Transfer-Encoding']) && $response['headers']['Content-Transfer-Encoding'] == 'binary';
// Base64 decode when binary
if ($gzip || $binary) {
$body = base64_decode($response['body']);
}
return new static(isset($response['status']) ? $response['status'] : 200, isset($response['headers']) ? $response['headers'] : array(), $body);
}