Skip to content

Commit 6e0ba9c

Browse files
Merge branch '6.4' into 7.1
* 6.4: [HttpFoundation] Fix test [HttpFoundation] Revert risk change [Notifier] Fix GoIpTransport [HttpClient] Fix catching some invalid Location headers
2 parents 5ea4b77 + 29498a9 commit 6e0ba9c

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

CurlHttpClient.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ private static function createRedirectResolver(array $options, string $host, int
421421
try {
422422
$locationHasHost = false;
423423
$location = self::parseUrl($location);
424+
$url = self::parseUrl(curl_getinfo($ch, \CURLINFO_EFFECTIVE_URL));
425+
$url = self::resolveUrl($location, $url);
424426
} catch (InvalidArgumentException) {
425427
return null;
426428
}
@@ -441,9 +443,6 @@ private static function createRedirectResolver(array $options, string $host, int
441443
curl_setopt($ch, \CURLOPT_HTTPHEADER, $redirectHeaders['with_auth']);
442444
}
443445

444-
$url = self::parseUrl(curl_getinfo($ch, \CURLINFO_EFFECTIVE_URL));
445-
$url = self::resolveUrl($location, $url);
446-
447446
curl_setopt($ch, \CURLOPT_PROXY, self::getProxyUrl($options['proxy'], $url));
448447

449448
return implode('', $url);

NativeHttpClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,14 +383,14 @@ private static function createRedirectResolver(array $options, string $host, str
383383

384384
try {
385385
$url = self::parseUrl($location);
386+
$locationHasHost = isset($url['authority']);
387+
$url = self::resolveUrl($url, $info['url']);
386388
} catch (InvalidArgumentException) {
387389
$info['redirect_url'] = null;
388390

389391
return null;
390392
}
391393

392-
$locationHasHost = isset($url['authority']);
393-
$url = self::resolveUrl($url, $info['url']);
394394
$info['redirect_url'] = implode('', $url);
395395

396396
if ($info['redirect_count'] >= $maxRedirects) {

Tests/HttpClientTestCase.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,11 @@ public function testNoRedirectWithInvalidLocation()
494494
{
495495
$client = $this->getHttpClient(__FUNCTION__);
496496

497-
$response = $client->request('GET', 'http://localhost:8057/302-no-scheme');
497+
$response = $client->request('GET', 'http://localhost:8057/302?location=localhost:8067');
498+
499+
$this->assertSame(302, $response->getStatusCode());
500+
501+
$response = $client->request('GET', 'http://localhost:8057/302?location=http:localhost');
498502

499503
$this->assertSame(302, $response->getStatusCode());
500504
}

0 commit comments

Comments
 (0)