mirror of
https://github.com/guzzle/guzzle.git
synced 2025-01-17 21:38:16 +01:00
Merge pull request #2454 from alexeyshockov/idn-conversion-fix
Better defaults for PHP installations with old ICU lib
This commit is contained in:
commit
2eda2b9c75
@ -561,7 +561,7 @@ idn_conversion
|
||||
:Types:
|
||||
- bool
|
||||
- int
|
||||
:Default: ``true`` if ``intl`` extension is available, ``false`` otherwise
|
||||
:Default: ``true`` if ``intl`` extension is available (and ICU library is 4.6+ for PHP 7.2+), ``false`` otherwise
|
||||
:Constant: ``GuzzleHttp\RequestOptions::IDN_CONVERSION``
|
||||
|
||||
.. code-block:: php
|
||||
|
@ -218,7 +218,8 @@ class Client implements ClientInterface
|
||||
if ($uri->getHost() && isset($config['idn_conversion']) && ($config['idn_conversion'] !== false)) {
|
||||
$idnOptions = ($config['idn_conversion'] === true) ? IDNA_DEFAULT : $config['idn_conversion'];
|
||||
|
||||
$asciiHost = idn_to_ascii($uri->getHost(), $idnOptions, INTL_IDNA_VARIANT_UTS46, $info);
|
||||
$idnaVariant = defined('INTL_IDNA_VARIANT_UTS46') ? INTL_IDNA_VARIANT_UTS46 : 0;
|
||||
$asciiHost = idn_to_ascii($uri->getHost(), $idnOptions, $idnaVariant, $info);
|
||||
if ($asciiHost === false) {
|
||||
$errorBitSet = isset($info['errors']) ? $info['errors'] : 0;
|
||||
|
||||
@ -267,7 +268,14 @@ class Client implements ClientInterface
|
||||
];
|
||||
|
||||
// idn_to_ascii() is a part of ext-intl and might be not available
|
||||
$defaults['idn_conversion'] = function_exists('idn_to_ascii');
|
||||
$defaults['idn_conversion'] = function_exists('idn_to_ascii')
|
||||
// Old ICU versions don't have this constant, so we are basically stuck (see https://github.com/guzzle/guzzle/pull/2424
|
||||
// and https://github.com/guzzle/guzzle/issues/2448 for details)
|
||||
&& (
|
||||
defined('INTL_IDNA_VARIANT_UTS46')
|
||||
||
|
||||
PHP_VERSION_ID < 70200
|
||||
);
|
||||
|
||||
// Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user