Skip to content

Commit 43f2764

Browse files
[HttpClient] Fix empty hosts in option "resolve"
1 parent 582cf3a commit 43f2764

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

HttpClientTrait.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,8 @@ private static function mergeDefaultOptions(array $options, array $defaultOption
198198
$options['resolve'] = [];
199199
foreach ($resolve as $k => $v) {
200200
if ('' === $v = (string) $v) {
201-
throw new InvalidArgumentException(sprintf('Option "resolve" for host "%s" cannot be empty.', $k));
202-
}
203-
if ('[' === $v[0] && ']' === substr($v, -1) && str_contains($v, ':')) {
201+
$v = null;
202+
} elseif ('[' === $v[0] && ']' === substr($v, -1) && str_contains($v, ':')) {
204203
$v = substr($v, 1, -1);
205204
}
206205

@@ -228,9 +227,8 @@ private static function mergeDefaultOptions(array $options, array $defaultOption
228227
if ($resolve = $defaultOptions['resolve'] ?? false) {
229228
foreach ($resolve as $k => $v) {
230229
if ('' === $v = (string) $v) {
231-
throw new InvalidArgumentException(sprintf('Option "resolve" for host "%s" cannot be empty.', $k));
232-
}
233-
if ('[' === $v[0] && ']' === substr($v, -1) && str_contains($v, ':')) {
230+
$v = null;
231+
} elseif ('[' === $v[0] && ']' === substr($v, -1) && str_contains($v, ':')) {
234232
$v = substr($v, 1, -1);
235233
}
236234

0 commit comments

Comments
 (0)