Skip to content

Commit 5e56b0d

Browse files
Merge pull request #4 from whikloj/issue-363
Pass url into curlinfo hook for effective url
2 parents 538540d + a3aa80a commit 5e56b0d

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/VCR/LibraryHooks/CurlHook.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ public static function curlGetinfo(CurlHandle $curlHandle, int $option = 0)
281281
if (isset(self::$responses[(int) $curlHandle])) {
282282
return CurlHelper::getCurlOptionFromResponse(
283283
self::$responses[(int) $curlHandle],
284+
self::$requests[(int) $curlHandle]->getUrl(),
284285
$option
285286
);
286287
} elseif (isset(self::$lastErrors[(int) $curlHandle])) {

src/VCR/Util/CurlHelper.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,15 @@ public static function handleOutput(Response $response, array $curlOptions, Curl
8888
}
8989

9090
/**
91-
* @param int $option cURL option to get
91+
* @param Response $response response to get cURL option from
92+
* @param string|null $url the URL this response is for
93+
* @param int $option cURL option to get
9294
*
9395
* @throws \BadMethodCallException
9496
*
9597
* @return mixed value of the cURL option
9698
*/
97-
public static function getCurlOptionFromResponse(Response $response, int $option = 0)
99+
public static function getCurlOptionFromResponse(Response $response, ?string $url, int $option = 0)
98100
{
99101
switch ($option) {
100102
case 0: // 0 == array of all curl options
@@ -116,6 +118,9 @@ public static function getCurlOptionFromResponse(Response $response, int $option
116118
case \CURLINFO_APPCONNECT_TIME:
117119
$info = '';
118120
break;
121+
case \CURLINFO_EFFECTIVE_URL:
122+
$info = $url;
123+
break;
119124
default:
120125
$info = $response->getCurlInfo(self::$curlInfoList[$option]);
121126
break;

tests/Unit/Util/CurlHelperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ public function testGetCurlOptionFromResponse(Response $response, $curlOption, $
407407
{
408408
$this->assertEquals(
409409
$expectedCurlOptionValue,
410-
CurlHelper::getCurlOptionFromResponse($response, $curlOption)
410+
CurlHelper::getCurlOptionFromResponse($response, '', $curlOption)
411411
);
412412
}
413413

0 commit comments

Comments
 (0)