19 if (extension_loaded(
'uri_template')) {
21 return \uri_template($template, $variables);
30 return $uriTemplate->expand($template, $variables);
43 switch (gettype($input)) {
45 return 'object(' . get_class($input) .
')';
47 return 'array(' . count($input) .
')';
52 return str_replace(
'double(',
'float(', rtrim(ob_get_clean()));
67 foreach ($lines as $line) {
68 $parts = explode(
':', $line, 2);
69 $headers[trim($parts[0])][] = isset($parts[1])
86 if (is_resource($value)) {
88 } elseif (defined(
'STDOUT')) {
92 return fopen(
'php://output',
'w');
106 if (function_exists(
'curl_multi_exec') && function_exists(
'curl_exec')) {
108 } elseif (function_exists(
'curl_exec')) {
110 } elseif (function_exists(
'curl_multi_exec')) {
114 if (ini_get(
'allow_url_fopen')) {
118 } elseif (!$handler) {
119 throw new \RuntimeException(
'GuzzleHttp requires cURL, the '
120 .
'allow_url_fopen ini setting, or a custom HTTP handler.');
133 static $defaultAgent =
'';
135 if (!$defaultAgent) {
137 if (extension_loaded(
'curl') && function_exists(
'curl_version')) {
138 $defaultAgent .=
' curl/' . \curl_version()[
'version'];
140 $defaultAgent .=
' PHP/' . PHP_VERSION;
143 return $defaultAgent;
162 static $cached =
null;
165 '/etc/pki/tls/certs/ca-bundle.crt',
167 '/etc/ssl/certs/ca-certificates.crt',
169 '/usr/local/share/certs/ca-root-nss.crt',
171 '/var/lib/ca-certificates/ca-bundle.pem',
173 '/usr/local/etc/openssl/cert.pem',
175 '/etc/ca-certificates.crt',
177 'C:\\windows\\system32\\curl-ca-bundle.crt',
178 'C:\\windows\\curl-ca-bundle.crt',
185 if ($ca = ini_get(
'openssl.cafile')) {
186 return $cached = $ca;
189 if ($ca = ini_get(
'curl.cainfo')) {
190 return $cached = $ca;
193 foreach ($cafiles as $filename) {
194 if (file_exists($filename)) {
195 return $cached = $filename;
199 throw new \RuntimeException(
201 No system CA bundle could be found in
any of the the common system locations.
202 PHP versions earlier than 5.6 are not properly configured to use the system
's
203 CA bundle by default. In order to verify peer certificates, you will need to
204 supply the path on disk to a certificate bundle to the 'verify
' request
205 option: http://docs.guzzlephp.org/en/latest/clients.html#verify. If you do not
206 need a specific certificate bundle, then Mozilla provides a commonly used CA
207 bundle which can be downloaded here (provided by the maintainer of cURL):
208 https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt. Once
209 you have a CA bundle available on disk, you can set the 'openssl.cafile
' PHP
210 ini setting to point to the path to the file, allowing you to omit the 'verify
'
211 request option. See http://curl.haxx.se/docs/sslcerts.html for more
225 function normalize_header_keys(array $headers)
228 foreach (array_keys($headers) as $key) {
229 $result[strtolower($key)] = $key;
254 function is_host_in_noproxy($host, array $noProxyArray)
256 if (strlen($host) === 0) {
257 throw new \InvalidArgumentException('Empty host provided
');
260 // Strip port if present.
261 if (strpos($host, ':
')) {
262 $host = explode($host, ':
', 2)[0];
265 foreach ($noProxyArray as $area) {
266 // Always match on wildcards.
269 } elseif (empty($area)) {
270 // Don't match on empty values.
272 } elseif ($area === $host) {
278 $area =
'.' . ltrim($area,
'.');
279 if (substr($host, -(strlen($area))) === $area) {
301 function json_decode($json, $assoc =
false, $depth = 512, $options = 0)
304 if (JSON_ERROR_NONE !== json_last_error()) {
306 'json_decode error: ' . json_last_error_msg()
327 if (JSON_ERROR_NONE !== json_last_error()) {
329 'json_encode error: ' . json_last_error_msg()