Skip to content

Commit 54a2306

Browse files
committed
Merge branch '5.1' into 5.2
* 5.1: [HttpFoundation] Make test pass without Xdebug. [Mime] Leverage PHP 8's detection of CSV files. [HttpFoundation] Make sure we reuse the current PHP binary for the webserver process in functional tests. [FrameworkBundle] TextDescriptor::formatControllerLink checked method… Fix CS [HttpClient] throw clearer error when no scheme is provided Fix github pr template and include 5.2 for bugfixes [HttpFoundation] Ignore stack trace printed by Xdebug 3. fix lexing backslashes in single quoted strings
2 parents 5b9fc5d + 9287d86 commit 54a2306

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

HttpClientTrait.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,10 @@ private static function resolveUrl(array $url, ?array $base, array $queryDefault
391391
throw new InvalidArgumentException(sprintf('Invalid "base_uri" option: host or scheme is missing in "%s".', implode('', $base)));
392392
}
393393

394+
if (null === $url['scheme'] && (null === $base || null === $base['scheme'])) {
395+
throw new InvalidArgumentException(sprintf('Invalid URL: scheme is missing in "%s". Did you forget to add "http(s)://"?', implode('', $base ?? $url)));
396+
}
397+
394398
if (null === $base && '' === $url['scheme'].$url['authority']) {
395399
throw new InvalidArgumentException(sprintf('Invalid URL: no "base_uri" option was provided and host or scheme is missing in "%s".', implode('', $url)));
396400
}

Tests/HttpClientTraitTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\HttpClient\Tests;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\HttpClient\Exception\InvalidArgumentException;
1516
use Symfony\Component\HttpClient\HttpClientTrait;
1617
use Symfony\Contracts\HttpClient\HttpClientInterface;
1718

@@ -120,6 +121,20 @@ public function provideResolveUrl(): array
120121
];
121122
}
122123

124+
public function testResolveUrlWithoutScheme()
125+
{
126+
$this->expectException(InvalidArgumentException::class);
127+
$this->expectExceptionMessage('Invalid URL: scheme is missing in "//localhost:8080". Did you forget to add "http(s)://"?');
128+
self::resolveUrl(self::parseUrl('localhost:8080'), null);
129+
}
130+
131+
public function testResolveBaseUrlWitoutScheme()
132+
{
133+
$this->expectException(InvalidArgumentException::class);
134+
$this->expectExceptionMessage('Invalid URL: scheme is missing in "//localhost:8081". Did you forget to add "http(s)://"?');
135+
self::resolveUrl(self::parseUrl('/foo'), self::parseUrl('localhost:8081'));
136+
}
137+
123138
/**
124139
* @dataProvider provideParseUrl
125140
*/

0 commit comments

Comments
 (0)