8000 bug #38173 [HttpClient][HttpClientTrait] don't calculate alternatives… · symfony/symfony@61c1175 · GitHub
[go: up one dir, main page]

Skip to content
< 65FC /div>

Commit 61c1175

Browse files
bug #38173 [HttpClient][HttpClientTrait] don't calculate alternatives if option is auth_ntlm (ybenhssaien)
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- [HttpClient][HttpClientTrait] don't calculate alternatives if option is auth_ntlm | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | no | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> If option is `auth_ntlm` an exception is thrown, `$alternatives` then is not used. Commits ------- ab1a96c [HttpClient][HttpClientTrait] don't calculate alternatives if option is auth_ntlm
2 parents e368bb4 + ab1a96c commit 61c1175

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/Symfony/Component/HttpClient/HttpClientTrait.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private static function prepareRequest(?string $method, ?string $url, array $opt
111111
}
112112

113113
if (isset($options['auth_bearer']) && (!\is_string($options['auth_bearer']) || !preg_match('{^[-._=~+/0-9a-zA-Z]++$}', $options['auth_bearer']))) {
114-
throw new InvalidArgumentException(sprintf('Option "auth_bearer" must be a string containing only characters from the base 64 alphabet, %s given.', \is_string($options['auth_bearer']) ? 'invalid string' : '"'.\gettype($options['auth_bearer']).'"'));
114+
throw new InvalidArgumentException(sprintf('Option "auth_bearer" must be a string containing only characters from the base 64 alphabet, '.(\is_string($options['auth_bearer']) ? 'invalid string given.' : '"%s" given.'), \gettype($options['auth_bearer'])));
115115
}
116116

117117
if (isset($options['auth_basic'], $options['auth_bearer'])) {
@@ -197,6 +197,16 @@ private static function mergeDefaultOptions(array $options, array $defaultOption
197197
continue;
198198
}
199199

200+
if ('auth_ntlm' === $name) {
201+
if (!\extension_loaded('curl')) {
202+
$msg = 'try installing the "curl" extension to use "%s" instead.';
203+
} else {
204+
$msg = 'try using "%s" instead.';
205+
}
206+
207+
throw new InvalidArgumentException(sprintf('Option "auth_ntlm" is not supported by "%s", '.$msg, __CLASS__, CurlHttpClient::class));
208+
}
209+
200210
$alternatives = [];
201211

202212
foreach ($defaultOptions as $key => $v) {
@@ -205,10 +215,6 @@ private static function mergeDefaultOptions(array $options, array $defaultOption
205215
}
206216
}
207217

208-
if ('auth_ntlm' === $name) {
209-
throw new InvalidArgumentException(sprintf('Option "auth_ntlm" is not supported by "%s", try using CurlHttpClient instead.', __CLASS__));
210-
}
211-
212218
throw new InvalidArgumentException(sprintf('Unsupported option "%s" passed to "%s", did you mean "%s"?', $name, __CLASS__, implode('", "', $alternatives ?: array_keys($defaultOptions))));
213219
}
214220

0 commit comments

Comments
 (0)
0