diff --git a/src/VCR/LibraryHooks/CurlHook.php b/src/VCR/LibraryHooks/CurlHook.php index d2e46ee86..d8b12fe6d 100644 --- a/src/VCR/LibraryHooks/CurlHook.php +++ b/src/VCR/LibraryHooks/CurlHook.php @@ -281,6 +281,7 @@ public static function curlGetinfo(CurlHandle $curlHandle, int $option = 0) if (isset(self::$responses[(int) $curlHandle])) { return CurlHelper::getCurlOptionFromResponse( self::$responses[(int) $curlHandle], + self::$requests[(int) $curlHandle]->getUrl(), $option ); } elseif (isset(self::$lastErrors[(int) $curlHandle])) { diff --git a/src/VCR/Util/CurlHelper.php b/src/VCR/Util/CurlHelper.php index 2b6b6c1f3..766baf395 100644 --- a/src/VCR/Util/CurlHelper.php +++ b/src/VCR/Util/CurlHelper.php @@ -82,13 +82,15 @@ public static function handleOutput(Response $response, array $curlOptions, Curl } /** - * @param int $option cURL option to get + * @param Response $response response to get cURL option from + * @param string|null $url the URL this response is for + * @param int $option cURL option to get * * @throws \BadMethodCallException * * @return mixed value of the cURL option */ - public static function getCurlOptionFromResponse(Response $response, int $option = 0) + public static function getCurlOptionFromResponse(Response $response, ?string $url, int $option = 0) { switch ($option) { case 0: // 0 == array of all curl options @@ -109,6 +111,9 @@ public static function getCurlOptionFromResponse(Response $response, int $option case \CURLPROXY_HTTPS: $info = ''; break; + case \CURLINFO_EFFECTIVE_URL: + $info = $url; + break; default: $info = $response->getCurlInfo(self::$curlInfoList[$option]); break; diff --git a/tests/Unit/Util/CurlHelperTest.php b/tests/Unit/Util/CurlHelperTest.php index 8b9e81e5d..13ee00db2 100644 --- a/tests/Unit/Util/CurlHelperTest.php +++ b/tests/Unit/Util/CurlHelperTest.php @@ -407,7 +407,7 @@ public function testGetCurlOptionFromResponse(Response $response, $curlOption, $ { $this->assertEquals( $expectedCurlOptionValue, - CurlHelper::getCurlOptionFromResponse($response, $curlOption) + CurlHelper::getCurlOptionFromResponse($response, '', $curlOption) ); }