/** * Returns a cURL option from a Response. * * @param Response $response Response to get cURL option from. * @param integer $option cURL option to get. * * @throws \BadMethodCallException * @return mixed Value of the cURL option. */ public static function getCurlOptionFromResponse(Response $response, $option = 0) { switch ($option) { case 0: // 0 == array of all curl options $info = array(); foreach (self::$curlInfoList as $option => $key) { $info[$key] = $response->getInfo($option); } break; case CURLINFO_HTTP_CODE: $info = $response->getStatusCode(); break; case CURLINFO_SIZE_DOWNLOAD: $info = $response->getHeader('Content-Length'); break; default: $info = $response->getInfo($option); break; } if (!is_null($info)) { return $info; } $constants = get_defined_constants(true); $constantNames = array_flip($constants['curl']); throw new \BadMethodCallException("Not implemented: {$constantNames[$option]} ({$option}) "); }
/** * Returns a HTTP status line from specified response. * * @param Response $response * @return string HTTP status line. */ public static function formatAsStatusString(Response $response) { return 'HTTP/' . $response->getHttpVersion() . ' ' . $response->getStatusCode() . ' ' . $response->getStatusMessage(); }