Update to Drupal 8.1.7. For more information, see https://www.drupal.org/project/drupal/releases/8.1.7
This commit is contained in:
parent
38ba7c357d
commit
e9f047ccf8
61 changed files with 1613 additions and 561 deletions
5
vendor/guzzlehttp/guzzle/.travis.yml
vendored
5
vendor/guzzlehttp/guzzle/.travis.yml
vendored
|
@ -1,5 +1,7 @@
|
|||
language: php
|
||||
|
||||
sudo: false
|
||||
|
||||
php:
|
||||
- 5.5
|
||||
- 5.6
|
||||
|
@ -12,16 +14,17 @@ before_script:
|
|||
- composer install --no-interaction --prefer-source --dev
|
||||
- ~/.nvm/nvm.sh install v0.6.14
|
||||
- ~/.nvm/nvm.sh run v0.6.14
|
||||
- '[ "$TRAVIS_PHP_VERSION" != "7.0" ] || echo "xdebug.overload_var_dump = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini'
|
||||
|
||||
script: make test
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: hhvm
|
||||
- php: 7.0
|
||||
fast_finish: true
|
||||
|
||||
before_deploy:
|
||||
- rvm 1.9.3 do gem install mime-types -v 2.6.2
|
||||
- make package
|
||||
|
||||
deploy:
|
||||
|
|
44
vendor/guzzlehttp/guzzle/CHANGELOG.md
vendored
44
vendor/guzzlehttp/guzzle/CHANGELOG.md
vendored
|
@ -1,5 +1,49 @@
|
|||
# CHANGELOG
|
||||
|
||||
## 6.2.1 - 2016-07-18
|
||||
|
||||
* Address HTTP_PROXY security vulnerability, CVE-2016-5385:
|
||||
https://httpoxy.org/
|
||||
* Fixing timeout bug with StreamHandler:
|
||||
https://github.com/guzzle/guzzle/pull/1488
|
||||
* Only read up to `Content-Length` in PHP StreamHandler to avoid timeouts when
|
||||
a server does not honor `Connection: close`.
|
||||
* Ignore URI fragment when sending requests.
|
||||
|
||||
## 6.2.0 - 2016-03-21
|
||||
|
||||
* Feature: added `GuzzleHttp\json_encode` and `GuzzleHttp\json_decode`.
|
||||
https://github.com/guzzle/guzzle/pull/1389
|
||||
* Bug fix: Fix sleep calculation when waiting for delayed requests.
|
||||
https://github.com/guzzle/guzzle/pull/1324
|
||||
* Feature: More flexible history containers.
|
||||
https://github.com/guzzle/guzzle/pull/1373
|
||||
* Bug fix: defer sink stream opening in StreamHandler.
|
||||
https://github.com/guzzle/guzzle/pull/1377
|
||||
* Bug fix: do not attempt to escape cookie values.
|
||||
https://github.com/guzzle/guzzle/pull/1406
|
||||
* Feature: report original content encoding and length on decoded responses.
|
||||
https://github.com/guzzle/guzzle/pull/1409
|
||||
* Bug fix: rewind seekable request bodies before dispatching to cURL.
|
||||
https://github.com/guzzle/guzzle/pull/1422
|
||||
* Bug fix: provide an empty string to `http_build_query` for HHVM workaround.
|
||||
https://github.com/guzzle/guzzle/pull/1367
|
||||
|
||||
## 6.1.1 - 2015-11-22
|
||||
|
||||
* Bug fix: Proxy::wrapSync() now correctly proxies to the appropriate handler
|
||||
https://github.com/guzzle/guzzle/commit/911bcbc8b434adce64e223a6d1d14e9a8f63e4e4
|
||||
* Feature: HandlerStack is now more generic.
|
||||
https://github.com/guzzle/guzzle/commit/f2102941331cda544745eedd97fc8fd46e1ee33e
|
||||
* Bug fix: setting verify to false in the StreamHandler now disables peer
|
||||
verification. https://github.com/guzzle/guzzle/issues/1256
|
||||
* Feature: Middleware now uses an exception factory, including more error
|
||||
context. https://github.com/guzzle/guzzle/pull/1282
|
||||
* Feature: better support for disabled functions.
|
||||
https://github.com/guzzle/guzzle/pull/1287
|
||||
* Bug fix: fixed regression where MockHandler was not using `sink`.
|
||||
https://github.com/guzzle/guzzle/pull/1292
|
||||
|
||||
## 6.1.0 - 2015-09-08
|
||||
|
||||
* Feature: Added the `on_stats` request option to provide access to transfer
|
||||
|
|
2
vendor/guzzlehttp/guzzle/LICENSE
vendored
2
vendor/guzzlehttp/guzzle/LICENSE
vendored
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2011-2015 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
|
||||
Copyright (c) 2011-2016 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
10
vendor/guzzlehttp/guzzle/README.md
vendored
10
vendor/guzzlehttp/guzzle/README.md
vendored
|
@ -1,7 +1,7 @@
|
|||
Guzzle, PHP HTTP client
|
||||
=======================
|
||||
|
||||
[](http://travis-ci.org/guzzle/guzzle)
|
||||
[](https://travis-ci.org/guzzle/guzzle)
|
||||
|
||||
Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and
|
||||
trivial to integrate with web services.
|
||||
|
@ -18,13 +18,13 @@ trivial to integrate with web services.
|
|||
- Middleware system allows you to augment and compose client behavior.
|
||||
|
||||
```php
|
||||
$client = new GuzzleHttp\Client();
|
||||
$client = new \GuzzleHttp\Client();
|
||||
$res = $client->request('GET', 'https://api.github.com/user', [
|
||||
'auth' => ['user', 'pass']
|
||||
]);
|
||||
echo $res->getStatusCode();
|
||||
// "200"
|
||||
echo $res->getHeader('content-type');
|
||||
// 200
|
||||
echo $res->getHeaderLine('content-type');
|
||||
// 'application/json; charset=utf8'
|
||||
echo $res->getBody();
|
||||
// {"type":"User"...'
|
||||
|
@ -57,7 +57,7 @@ curl -sS https://getcomposer.org/installer | php
|
|||
Next, run the Composer command to install the latest stable version of Guzzle:
|
||||
|
||||
```bash
|
||||
composer.phar require guzzlehttp/guzzle
|
||||
php composer.phar require guzzlehttp/guzzle
|
||||
```
|
||||
|
||||
After installing, you need to require Composer's autoloader:
|
||||
|
|
12
vendor/guzzlehttp/guzzle/composer.json
vendored
12
vendor/guzzlehttp/guzzle/composer.json
vendored
|
@ -13,14 +13,14 @@
|
|||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.5.0",
|
||||
"guzzlehttp/psr7": "~1.1",
|
||||
"guzzlehttp/promises": "~1.0"
|
||||
"php": ">=5.5",
|
||||
"guzzlehttp/psr7": "^1.3.1",
|
||||
"guzzlehttp/promises": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-curl": "*",
|
||||
"phpunit/phpunit": "~4.0",
|
||||
"psr/log": "~1.0"
|
||||
"phpunit/phpunit": "^4.0",
|
||||
"psr/log": "^1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"files": ["src/functions_include.php"],
|
||||
|
@ -35,7 +35,7 @@
|
|||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "6.1-dev"
|
||||
"dev-master": "6.2-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
59
vendor/guzzlehttp/guzzle/src/Client.php
vendored
59
vendor/guzzlehttp/guzzle/src/Client.php
vendored
|
@ -93,7 +93,7 @@ class Client implements ClientInterface
|
|||
$options = $this->prepareDefaults($options);
|
||||
|
||||
return $this->transfer(
|
||||
$request->withUri($this->buildUri($request->getUri(), $options)),
|
||||
$request->withUri($this->buildUri($request->getUri(), $options), $request->hasHeader('Host')),
|
||||
$options
|
||||
);
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ class Client implements ClientInterface
|
|||
return $this->sendAsync($request, $options)->wait();
|
||||
}
|
||||
|
||||
public function requestAsync($method, $uri = null, array $options = [])
|
||||
public function requestAsync($method, $uri = '', array $options = [])
|
||||
{
|
||||
$options = $this->prepareDefaults($options);
|
||||
// Remove request modifying parameter because it can be done up-front.
|
||||
|
@ -123,7 +123,7 @@ class Client implements ClientInterface
|
|||
return $this->transfer($request, $options);
|
||||
}
|
||||
|
||||
public function request($method, $uri = null, array $options = [])
|
||||
public function request($method, $uri = '', array $options = [])
|
||||
{
|
||||
$options[RequestOptions::SYNCHRONOUS] = true;
|
||||
return $this->requestAsync($method, $uri, $options)->wait();
|
||||
|
@ -138,11 +138,14 @@ class Client implements ClientInterface
|
|||
|
||||
private function buildUri($uri, array $config)
|
||||
{
|
||||
if (!isset($config['base_uri'])) {
|
||||
return $uri instanceof UriInterface ? $uri : new Psr7\Uri($uri);
|
||||
// for BC we accept null which would otherwise fail in uri_for
|
||||
$uri = Psr7\uri_for($uri === null ? '' : $uri);
|
||||
|
||||
if (isset($config['base_uri'])) {
|
||||
$uri = Psr7\Uri::resolve(Psr7\uri_for($config['base_uri']), $uri);
|
||||
}
|
||||
|
||||
return Psr7\Uri::resolve(Psr7\uri_for($config['base_uri']), $uri);
|
||||
return $uri->getScheme() === '' ? $uri->withScheme('http') : $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -160,9 +163,13 @@ class Client implements ClientInterface
|
|||
'cookies' => false
|
||||
];
|
||||
|
||||
// Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set
|
||||
if ($proxy = getenv('HTTP_PROXY')) {
|
||||
$defaults['proxy']['http'] = $proxy;
|
||||
// Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set.
|
||||
|
||||
// We can only trust the HTTP_PROXY environment variable in a CLI
|
||||
// process due to the fact that PHP has no reliable mechanism to
|
||||
// get environment variables that start with "HTTP_".
|
||||
if (php_sapi_name() == 'cli' && getenv('HTTP_PROXY')) {
|
||||
$defaults['proxy']['http'] = getenv('HTTP_PROXY');
|
||||
}
|
||||
|
||||
if ($proxy = getenv('HTTPS_PROXY')) {
|
||||
|
@ -173,7 +180,7 @@ class Client implements ClientInterface
|
|||
$cleanedNoProxy = str_replace(' ', '', $noProxy);
|
||||
$defaults['proxy']['no'] = explode(',', $cleanedNoProxy);
|
||||
}
|
||||
|
||||
|
||||
$this->config = $config + $defaults;
|
||||
|
||||
if (!empty($config['cookies']) && $config['cookies'] === true) {
|
||||
|
@ -255,7 +262,7 @@ class Client implements ClientInterface
|
|||
unset($options['save_to']);
|
||||
}
|
||||
|
||||
// exceptions -> http_error
|
||||
// exceptions -> http_errors
|
||||
if (isset($options['exceptions'])) {
|
||||
$options['http_errors'] = $options['exceptions'];
|
||||
unset($options['exceptions']);
|
||||
|
@ -291,15 +298,20 @@ class Client implements ClientInterface
|
|||
. 'x-www-form-urlencoded requests, and the multipart '
|
||||
. 'option to send multipart/form-data requests.');
|
||||
}
|
||||
$options['body'] = http_build_query($options['form_params'], null, '&');
|
||||
$options['body'] = http_build_query($options['form_params'], '', '&');
|
||||
unset($options['form_params']);
|
||||
$options['_conditional']['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||
}
|
||||
|
||||
if (isset($options['multipart'])) {
|
||||
$elements = $options['multipart'];
|
||||
$options['body'] = new Psr7\MultipartStream($options['multipart']);
|
||||
unset($options['multipart']);
|
||||
$options['body'] = new Psr7\MultipartStream($elements);
|
||||
}
|
||||
|
||||
if (isset($options['json'])) {
|
||||
$options['body'] = \GuzzleHttp\json_encode($options['json']);
|
||||
unset($options['json']);
|
||||
$options['_conditional']['Content-Type'] = 'application/json';
|
||||
}
|
||||
|
||||
if (!empty($options['decode_content'])
|
||||
|
@ -325,13 +337,10 @@ class Client implements ClientInterface
|
|||
unset($options['body']);
|
||||
}
|
||||
|
||||
if (!empty($options['auth'])) {
|
||||
if (!empty($options['auth']) && is_array($options['auth'])) {
|
||||
$value = $options['auth'];
|
||||
$type = is_array($value)
|
||||
? (isset($value[2]) ? strtolower($value[2]) : 'basic')
|
||||
: $value;
|
||||
$config['auth'] = $value;
|
||||
switch (strtolower($type)) {
|
||||
$type = isset($value[2]) ? strtolower($value[2]) : 'basic';
|
||||
switch ($type) {
|
||||
case 'basic':
|
||||
$modify['set_headers']['Authorization'] = 'Basic '
|
||||
. base64_encode("$value[0]:$value[1]");
|
||||
|
@ -356,10 +365,12 @@ class Client implements ClientInterface
|
|||
unset($options['query']);
|
||||
}
|
||||
|
||||
if (isset($options['json'])) {
|
||||
$modify['body'] = Psr7\stream_for(json_encode($options['json']));
|
||||
$options['_conditional']['Content-Type'] = 'application/json';
|
||||
unset($options['json']);
|
||||
// Ensure that sink is not an invalid value.
|
||||
if (isset($options['sink'])) {
|
||||
// TODO: Add more sink validation?
|
||||
if (is_bool($options['sink'])) {
|
||||
throw new \InvalidArgumentException('sink must not be a boolean');
|
||||
}
|
||||
}
|
||||
|
||||
$request = Psr7\modify_request($request, $modify);
|
||||
|
|
|
@ -12,7 +12,7 @@ use Psr\Http\Message\UriInterface;
|
|||
*/
|
||||
interface ClientInterface
|
||||
{
|
||||
const VERSION = '6.1.0';
|
||||
const VERSION = '6.2.1';
|
||||
|
||||
/**
|
||||
* Send an HTTP request.
|
||||
|
@ -44,7 +44,7 @@ interface ClientInterface
|
|||
* relative path to append to the base path of the client. The URL can
|
||||
* contain the query string as well.
|
||||
*
|
||||
* @param string $method HTTP method
|
||||
* @param string $method HTTP method.
|
||||
* @param string|UriInterface $uri URI object or string.
|
||||
* @param array $options Request options to apply.
|
||||
*
|
||||
|
|
|
@ -5,7 +5,7 @@ use Psr\Http\Message\RequestInterface;
|
|||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
/**
|
||||
* Cookie jar that stores cookies an an array
|
||||
* Cookie jar that stores cookies as an array
|
||||
*/
|
||||
class CookieJar implements CookieJarInterface
|
||||
{
|
||||
|
@ -58,22 +58,10 @@ class CookieJar implements CookieJarInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Quote the cookie value if it is not already quoted and it contains
|
||||
* problematic characters.
|
||||
*
|
||||
* @param string $value Value that may or may not need to be quoted
|
||||
*
|
||||
* @return string
|
||||
* @deprecated
|
||||
*/
|
||||
public static function getCookieValue($value)
|
||||
{
|
||||
if (substr($value, 0, 1) !== '"' &&
|
||||
substr($value, -1, 1) !== '"' &&
|
||||
strpbrk($value, ';,=')
|
||||
) {
|
||||
$value = '"' . $value . '"';
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
@ -82,7 +70,7 @@ class CookieJar implements CookieJarInterface
|
|||
* that survives between requests.
|
||||
*
|
||||
* @param SetCookie $cookie Being evaluated.
|
||||
* @param bool $allowSessionCookies If we should presist session cookies
|
||||
* @param bool $allowSessionCookies If we should persist session cookies
|
||||
* @return bool
|
||||
*/
|
||||
public static function shouldPersist(
|
||||
|
@ -245,10 +233,10 @@ class CookieJar implements CookieJarInterface
|
|||
if ($cookie->matchesPath($path) &&
|
||||
$cookie->matchesDomain($host) &&
|
||||
!$cookie->isExpired() &&
|
||||
(!$cookie->getSecure() || $scheme == 'https')
|
||||
(!$cookie->getSecure() || $scheme === 'https')
|
||||
) {
|
||||
$values[] = $cookie->getName() . '='
|
||||
. self::getCookieValue($cookie->getValue());
|
||||
. $cookie->getValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,9 +9,9 @@ class FileCookieJar extends CookieJar
|
|||
/** @var string filename */
|
||||
private $filename;
|
||||
|
||||
/** @var bool Control whether to presist session cookies or not. */
|
||||
/** @var bool Control whether to persist session cookies or not. */
|
||||
private $storeSessionCookies;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new FileCookieJar object
|
||||
*
|
||||
|
@ -55,7 +55,8 @@ class FileCookieJar extends CookieJar
|
|||
}
|
||||
}
|
||||
|
||||
if (false === file_put_contents($filename, json_encode($json))) {
|
||||
$jsonStr = \GuzzleHttp\json_encode($json);
|
||||
if (false === file_put_contents($filename, $jsonStr)) {
|
||||
throw new \RuntimeException("Unable to save file {$filename}");
|
||||
}
|
||||
}
|
||||
|
@ -73,9 +74,11 @@ class FileCookieJar extends CookieJar
|
|||
$json = file_get_contents($filename);
|
||||
if (false === $json) {
|
||||
throw new \RuntimeException("Unable to load file {$filename}");
|
||||
} elseif ($json === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = json_decode($json, true);
|
||||
$data = \GuzzleHttp\json_decode($json, true);
|
||||
if (is_array($data)) {
|
||||
foreach (json_decode($json, true) as $cookie) {
|
||||
$this->setCookie(new SetCookie($cookie));
|
||||
|
|
|
@ -9,7 +9,7 @@ class SessionCookieJar extends CookieJar
|
|||
/** @var string session key */
|
||||
private $sessionKey;
|
||||
|
||||
/** @var bool Control whether to presist session cookies or not. */
|
||||
/** @var bool Control whether to persist session cookies or not. */
|
||||
private $storeSessionCookies;
|
||||
|
||||
/**
|
||||
|
@ -56,11 +56,10 @@ class SessionCookieJar extends CookieJar
|
|||
*/
|
||||
protected function load()
|
||||
{
|
||||
$cookieJar = isset($_SESSION[$this->sessionKey])
|
||||
? $_SESSION[$this->sessionKey]
|
||||
: null;
|
||||
|
||||
$data = json_decode($cookieJar, true);
|
||||
if (!isset($_SESSION[$this->sessionKey])) {
|
||||
return;
|
||||
}
|
||||
$data = json_decode($_SESSION[$this->sessionKey], true);
|
||||
if (is_array($data)) {
|
||||
foreach ($data as $cookie) {
|
||||
$this->setCookie(new SetCookie($cookie));
|
||||
|
|
|
@ -86,8 +86,8 @@ class SetCookie
|
|||
{
|
||||
$str = $this->data['Name'] . '=' . $this->data['Value'] . '; ';
|
||||
foreach ($this->data as $k => $v) {
|
||||
if ($k != 'Name' && $k != 'Value' && $v !== null && $v !== false) {
|
||||
if ($k == 'Expires') {
|
||||
if ($k !== 'Name' && $k !== 'Value' && $v !== null && $v !== false) {
|
||||
if ($k === 'Expires') {
|
||||
$str .= 'Expires=' . gmdate('D, d M Y H:i:s \G\M\T', $v) . '; ';
|
||||
} else {
|
||||
$str .= ($v === true ? $k : "{$k}={$v}") . '; ';
|
||||
|
@ -307,7 +307,7 @@ class SetCookie
|
|||
$cookiePath = $this->getPath();
|
||||
|
||||
// Match on exact matches or when path is the default empty "/"
|
||||
if ($cookiePath == '/' || $cookiePath == $requestPath) {
|
||||
if ($cookiePath === '/' || $cookiePath == $requestPath) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -317,12 +317,12 @@ class SetCookie
|
|||
}
|
||||
|
||||
// Match if the last character of the cookie-path is "/"
|
||||
if (substr($cookiePath, -1, 1) == '/') {
|
||||
if (substr($cookiePath, -1, 1) === '/') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Match if the first character not included in cookie path is "/"
|
||||
return substr($requestPath, strlen($cookiePath), 1) == '/';
|
||||
return substr($requestPath, strlen($cookiePath), 1) === '/';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -77,26 +77,70 @@ class RequestException extends TransferException
|
|||
);
|
||||
}
|
||||
|
||||
$level = floor($response->getStatusCode() / 100);
|
||||
if ($level == '4') {
|
||||
$label = 'Client error response';
|
||||
$level = (int) floor($response->getStatusCode() / 100);
|
||||
if ($level === 4) {
|
||||
$label = 'Client error';
|
||||
$className = __NAMESPACE__ . '\\ClientException';
|
||||
} elseif ($level == '5') {
|
||||
$label = 'Server error response';
|
||||
} elseif ($level === 5) {
|
||||
$label = 'Server error';
|
||||
$className = __NAMESPACE__ . '\\ServerException';
|
||||
} else {
|
||||
$label = 'Unsuccessful response';
|
||||
$label = 'Unsuccessful request';
|
||||
$className = __CLASS__;
|
||||
}
|
||||
|
||||
$message = $label . ' [url] ' . $request->getUri()
|
||||
. ' [http method] ' . $request->getMethod()
|
||||
. ' [status code] ' . $response->getStatusCode()
|
||||
. ' [reason phrase] ' . $response->getReasonPhrase();
|
||||
// Server Error: `GET /` resulted in a `404 Not Found` response:
|
||||
// <html> ... (truncated)
|
||||
$message = sprintf(
|
||||
'%s: `%s` resulted in a `%s` response',
|
||||
$label,
|
||||
$request->getMethod() . ' ' . $request->getUri(),
|
||||
$response->getStatusCode() . ' ' . $response->getReasonPhrase()
|
||||
);
|
||||
|
||||
$summary = static::getResponseBodySummary($response);
|
||||
|
||||
if ($summary !== null) {
|
||||
$message .= ":\n{$summary}\n";
|
||||
}
|
||||
|
||||
return new $className($message, $request, $response, $previous, $ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a short summary of the response
|
||||
*
|
||||
* Will return `null` if the response is not printable.
|
||||
*
|
||||
* @param ResponseInterface $response
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public static function getResponseBodySummary(ResponseInterface $response)
|
||||
{
|
||||
$body = $response->getBody();
|
||||
|
||||
if (!$body->isSeekable()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$size = $body->getSize();
|
||||
$summary = $body->read(120);
|
||||
$body->rewind();
|
||||
|
||||
if ($size > 120) {
|
||||
$summary .= ' (truncated...)';
|
||||
}
|
||||
|
||||
// Matches any printable character, including unicode characters:
|
||||
// letters, marks, numbers, punctuation, spacing, and separators.
|
||||
if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/', $summary)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $summary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the request that caused the exception
|
||||
*
|
||||
|
|
|
@ -194,7 +194,7 @@ class CurlFactory implements CurlFactoryInterface
|
|||
$conf = [
|
||||
'_headers' => $easy->request->getHeaders(),
|
||||
CURLOPT_CUSTOMREQUEST => $easy->request->getMethod(),
|
||||
CURLOPT_URL => (string) $easy->request->getUri(),
|
||||
CURLOPT_URL => (string) $easy->request->getUri()->withFragment(''),
|
||||
CURLOPT_RETURNTRANSFER => false,
|
||||
CURLOPT_HEADER => false,
|
||||
CURLOPT_CONNECTTIMEOUT => 150,
|
||||
|
@ -265,6 +265,9 @@ class CurlFactory implements CurlFactoryInterface
|
|||
$this->removeHeader('Content-Length', $conf);
|
||||
}
|
||||
$body = $request->getBody();
|
||||
if ($body->isSeekable()) {
|
||||
$body->rewind();
|
||||
}
|
||||
$conf[CURLOPT_READFUNCTION] = function ($ch, $fd, $length) use ($body) {
|
||||
return $body->read($length);
|
||||
};
|
||||
|
@ -492,12 +495,14 @@ class CurlFactory implements CurlFactoryInterface
|
|||
|
||||
private function createHeaderFn(EasyHandle $easy)
|
||||
{
|
||||
if (!isset($easy->options['on_headers'])) {
|
||||
$onHeaders = null;
|
||||
} elseif (!is_callable($easy->options['on_headers'])) {
|
||||
throw new \InvalidArgumentException('on_headers must be callable');
|
||||
} else {
|
||||
if (isset($easy->options['on_headers'])) {
|
||||
$onHeaders = $easy->options['on_headers'];
|
||||
|
||||
if (!is_callable($onHeaders)) {
|
||||
throw new \InvalidArgumentException('on_headers must be callable');
|
||||
}
|
||||
} else {
|
||||
$onHeaders = null;
|
||||
}
|
||||
|
||||
return function ($ch, $h) use (
|
||||
|
@ -509,7 +514,7 @@ class CurlFactory implements CurlFactoryInterface
|
|||
if ($value === '') {
|
||||
$startingResponse = true;
|
||||
$easy->createResponse();
|
||||
if ($onHeaders) {
|
||||
if ($onHeaders !== null) {
|
||||
try {
|
||||
$onHeaders($easy->response);
|
||||
} catch (\Exception $e) {
|
||||
|
|
|
@ -192,6 +192,6 @@ class CurlMultiHandler
|
|||
}
|
||||
}
|
||||
|
||||
return max(0, $currentTime - $nextTime);
|
||||
return max(0, $nextTime - $currentTime) * 1000000;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,8 +56,13 @@ final class EasyHandle
|
|||
if (!empty($this->options['decode_content'])
|
||||
&& isset($normalizedKeys['content-encoding'])
|
||||
) {
|
||||
$headers['x-encoded-content-encoding']
|
||||
= $headers[$normalizedKeys['content-encoding']];
|
||||
unset($headers[$normalizedKeys['content-encoding']]);
|
||||
if (isset($normalizedKeys['content-length'])) {
|
||||
$headers['x-encoded-content-length']
|
||||
= $headers[$normalizedKeys['content-length']];
|
||||
|
||||
$bodyLength = (int) $this->sink->getSize();
|
||||
if ($bodyLength) {
|
||||
$headers[$normalizedKeys['content-length']] = $bodyLength;
|
||||
|
|
|
@ -27,7 +27,7 @@ class MockHandler implements \Countable
|
|||
* @param callable $onFulfilled Callback to invoke when the return value is fulfilled.
|
||||
* @param callable $onRejected Callback to invoke when the return value is rejected.
|
||||
*
|
||||
* @return MockHandler
|
||||
* @return HandlerStack
|
||||
*/
|
||||
public static function createWithMiddleware(
|
||||
array $queue = null,
|
||||
|
@ -74,7 +74,7 @@ class MockHandler implements \Countable
|
|||
$response = array_shift($this->queue);
|
||||
|
||||
if (is_callable($response)) {
|
||||
$response = $response($request, $options);
|
||||
$response = call_user_func($response, $request, $options);
|
||||
}
|
||||
|
||||
$response = $response instanceof \Exception
|
||||
|
@ -87,6 +87,19 @@ class MockHandler implements \Countable
|
|||
if ($this->onFulfilled) {
|
||||
call_user_func($this->onFulfilled, $value);
|
||||
}
|
||||
if (isset($options['sink'])) {
|
||||
$contents = (string) $value->getBody();
|
||||
$sink = $options['sink'];
|
||||
|
||||
if (is_resource($sink)) {
|
||||
fwrite($sink, $contents);
|
||||
} elseif (is_string($sink)) {
|
||||
file_put_contents($sink, $contents);
|
||||
} elseif ($sink instanceof \Psr\Http\Message\StreamInterface) {
|
||||
$sink->write($contents);
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
},
|
||||
function ($reason) use ($request, $options) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
namespace GuzzleHttp\Handler;
|
||||
|
||||
use GuzzleHttp\RequestOptions;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
/**
|
||||
|
@ -22,7 +23,7 @@ class Proxy
|
|||
callable $sync
|
||||
) {
|
||||
return function (RequestInterface $request, array $options) use ($default, $sync) {
|
||||
return empty($options['sync'])
|
||||
return empty($options[RequestOptions::SYNCHRONOUS])
|
||||
? $default($request, $options)
|
||||
: $sync($request, $options);
|
||||
};
|
||||
|
|
|
@ -105,7 +105,12 @@ class StreamHandler
|
|||
$headers = \GuzzleHttp\headers_from_lines($hdrs);
|
||||
list ($stream, $headers) = $this->checkDecode($options, $headers, $stream);
|
||||
$stream = Psr7\stream_for($stream);
|
||||
$sink = $this->createSink($stream, $options);
|
||||
$sink = $stream;
|
||||
|
||||
if (strcasecmp('HEAD', $request->getMethod())) {
|
||||
$sink = $this->createSink($stream, $options);
|
||||
}
|
||||
|
||||
$response = new Psr7\Response($status, $headers, $sink, $ver, $reason);
|
||||
|
||||
if (isset($options['on_headers'])) {
|
||||
|
@ -118,8 +123,14 @@ class StreamHandler
|
|||
}
|
||||
}
|
||||
|
||||
// Do not drain when the request is a HEAD request because they have
|
||||
// no body.
|
||||
if ($sink !== $stream) {
|
||||
$this->drain($stream, $sink);
|
||||
$this->drain(
|
||||
$stream,
|
||||
$sink,
|
||||
$response->getHeaderLine('Content-Length')
|
||||
);
|
||||
}
|
||||
|
||||
$this->invokeStats($options, $request, $startTime, $response, null);
|
||||
|
@ -138,7 +149,7 @@ class StreamHandler
|
|||
: fopen('php://temp', 'r+');
|
||||
|
||||
return is_string($sink)
|
||||
? new Psr7\Stream(Psr7\try_fopen($sink, 'r+'))
|
||||
? new Psr7\LazyOpenStream($sink, 'w+')
|
||||
: Psr7\stream_for($sink);
|
||||
}
|
||||
|
||||
|
@ -149,16 +160,21 @@ class StreamHandler
|
|||
$normalizedKeys = \GuzzleHttp\normalize_header_keys($headers);
|
||||
if (isset($normalizedKeys['content-encoding'])) {
|
||||
$encoding = $headers[$normalizedKeys['content-encoding']];
|
||||
if ($encoding[0] == 'gzip' || $encoding[0] == 'deflate') {
|
||||
if ($encoding[0] === 'gzip' || $encoding[0] === 'deflate') {
|
||||
$stream = new Psr7\InflateStream(
|
||||
Psr7\stream_for($stream)
|
||||
);
|
||||
$headers['x-encoded-content-encoding']
|
||||
= $headers[$normalizedKeys['content-encoding']];
|
||||
// Remove content-encoding header
|
||||
unset($headers[$normalizedKeys['content-encoding']]);
|
||||
// Fix content-length header
|
||||
if (isset($normalizedKeys['content-length'])) {
|
||||
$headers['x-encoded-content-length']
|
||||
= $headers[$normalizedKeys['content-length']];
|
||||
|
||||
$length = (int) $stream->getSize();
|
||||
if ($length == 0) {
|
||||
if ($length === 0) {
|
||||
unset($headers[$normalizedKeys['content-length']]);
|
||||
} else {
|
||||
$headers[$normalizedKeys['content-length']] = [$length];
|
||||
|
@ -176,13 +192,27 @@ class StreamHandler
|
|||
*
|
||||
* @param StreamInterface $source
|
||||
* @param StreamInterface $sink
|
||||
* @param string $contentLength Header specifying the amount of
|
||||
* data to read.
|
||||
*
|
||||
* @return StreamInterface
|
||||
* @throws \RuntimeException when the sink option is invalid.
|
||||
*/
|
||||
private function drain(StreamInterface $source, StreamInterface $sink)
|
||||
{
|
||||
Psr7\copy_to_stream($source, $sink);
|
||||
private function drain(
|
||||
StreamInterface $source,
|
||||
StreamInterface $sink,
|
||||
$contentLength
|
||||
) {
|
||||
// If a content-length header is provided, then stop reading once
|
||||
// that number of bytes has been read. This can prevent infinitely
|
||||
// reading from a stream when dealing with servers that do not honor
|
||||
// Connection: Close headers.
|
||||
Psr7\copy_to_stream(
|
||||
$source,
|
||||
$sink,
|
||||
strlen($contentLength) > 0 ? (int) $contentLength : -1
|
||||
);
|
||||
|
||||
$sink->seek(0);
|
||||
$source->close();
|
||||
|
||||
|
@ -279,7 +309,7 @@ class StreamHandler
|
|||
|
||||
return $this->createResource(
|
||||
function () use ($request, &$http_response_header, $context) {
|
||||
$resource = fopen($request->getUri(), 'r', null, $context);
|
||||
$resource = fopen((string) $request->getUri()->withFragment(''), 'r', null, $context);
|
||||
$this->lastHeaders = $http_response_header;
|
||||
return $resource;
|
||||
}
|
||||
|
@ -341,7 +371,9 @@ class StreamHandler
|
|||
|
||||
private function add_timeout(RequestInterface $request, &$options, $value, &$params)
|
||||
{
|
||||
$options['http']['timeout'] = $value;
|
||||
if ($value > 0) {
|
||||
$options['http']['timeout'] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
private function add_verify(RequestInterface $request, &$options, $value, &$params)
|
||||
|
@ -359,12 +391,14 @@ class StreamHandler
|
|||
}
|
||||
} elseif ($value === false) {
|
||||
$options['ssl']['verify_peer'] = false;
|
||||
$options['ssl']['verify_peer_name'] = false;
|
||||
return;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Invalid verify request option');
|
||||
}
|
||||
|
||||
$options['ssl']['verify_peer'] = true;
|
||||
$options['ssl']['verify_peer_name'] = true;
|
||||
$options['ssl']['allow_self_signed'] = false;
|
||||
}
|
||||
|
||||
|
@ -416,7 +450,7 @@ class StreamHandler
|
|||
'bytes_transferred', 'bytes_max'];
|
||||
|
||||
$value = \GuzzleHttp\debug_resource($value);
|
||||
$ident = $request->getMethod() . ' ' . $request->getUri();
|
||||
$ident = $request->getMethod() . ' ' . $request->getUri()->withFragment('');
|
||||
$this->addNotification(
|
||||
$params,
|
||||
function () use ($ident, $value, $map, $args) {
|
||||
|
|
23
vendor/guzzlehttp/guzzle/src/HandlerStack.php
vendored
23
vendor/guzzlehttp/guzzle/src/HandlerStack.php
vendored
|
@ -62,11 +62,8 @@ class HandlerStack
|
|||
*/
|
||||
public function __invoke(RequestInterface $request, array $options)
|
||||
{
|
||||
if (!$this->cached) {
|
||||
$this->cached = $this->resolve();
|
||||
}
|
||||
$handler = $this->resolve();
|
||||
|
||||
$handler = $this->cached;
|
||||
return $handler($request, $options);
|
||||
}
|
||||
|
||||
|
@ -193,15 +190,19 @@ class HandlerStack
|
|||
*/
|
||||
public function resolve()
|
||||
{
|
||||
if (!($prev = $this->handler)) {
|
||||
throw new \LogicException('No handler has been specified');
|
||||
if (!$this->cached) {
|
||||
if (!($prev = $this->handler)) {
|
||||
throw new \LogicException('No handler has been specified');
|
||||
}
|
||||
|
||||
foreach (array_reverse($this->stack) as $fn) {
|
||||
$prev = $fn[0]($prev);
|
||||
}
|
||||
|
||||
$this->cached = $prev;
|
||||
}
|
||||
|
||||
foreach (array_reverse($this->stack) as $fn) {
|
||||
$prev = $fn[0]($prev);
|
||||
}
|
||||
|
||||
return $prev;
|
||||
return $this->cached;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
13
vendor/guzzlehttp/guzzle/src/Middleware.php
vendored
13
vendor/guzzlehttp/guzzle/src/Middleware.php
vendored
|
@ -2,9 +2,7 @@
|
|||
namespace GuzzleHttp;
|
||||
|
||||
use GuzzleHttp\Cookie\CookieJarInterface;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use GuzzleHttp\Exception\ServerException;
|
||||
use GuzzleHttp\Promise\RejectedPromise;
|
||||
use GuzzleHttp\Psr7;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
@ -64,9 +62,7 @@ final class Middleware
|
|||
if ($code < 400) {
|
||||
return $response;
|
||||
}
|
||||
throw $code > 499
|
||||
? new ServerException("Server error: $code", $request, $response)
|
||||
: new ClientException("Client error: $code", $request, $response);
|
||||
throw RequestException::create($request, $response);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
@ -79,9 +75,14 @@ final class Middleware
|
|||
* @param array $container Container to hold the history (by reference).
|
||||
*
|
||||
* @return callable Returns a function that accepts the next handler.
|
||||
* @throws \InvalidArgumentException if container is not an array or ArrayAccess.
|
||||
*/
|
||||
public static function history(array &$container)
|
||||
public static function history(&$container)
|
||||
{
|
||||
if (!is_array($container) && !$container instanceof \ArrayAccess) {
|
||||
throw new \InvalidArgumentException('history container must be an array or object implementing ArrayAccess');
|
||||
}
|
||||
|
||||
return function (callable $handler) use (&$container) {
|
||||
return function ($request, array $options) use ($handler, &$container) {
|
||||
return $handler($request, $options)->then(
|
||||
|
|
6
vendor/guzzlehttp/guzzle/src/Pool.php
vendored
6
vendor/guzzlehttp/guzzle/src/Pool.php
vendored
|
@ -52,11 +52,11 @@ class Pool implements PromisorInterface
|
|||
|
||||
$iterable = \GuzzleHttp\Promise\iter_for($requests);
|
||||
$requests = function () use ($iterable, $client, $opts) {
|
||||
foreach ($iterable as $rfn) {
|
||||
foreach ($iterable as $key => $rfn) {
|
||||
if ($rfn instanceof RequestInterface) {
|
||||
yield $client->sendAsync($rfn, $opts);
|
||||
yield $key => $client->sendAsync($rfn, $opts);
|
||||
} elseif (is_callable($rfn)) {
|
||||
yield $rfn($opts);
|
||||
yield $key => $rfn($opts);
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Each value yielded by '
|
||||
. 'the iterator must be a Psr7\Http\Message\RequestInterface '
|
||||
|
|
54
vendor/guzzlehttp/guzzle/src/UriTemplate.php
vendored
54
vendor/guzzlehttp/guzzle/src/UriTemplate.php
vendored
|
@ -15,25 +15,25 @@ class UriTemplate
|
|||
private $variables;
|
||||
|
||||
/** @var array Hash for quick operator lookups */
|
||||
private static $operatorHash = array(
|
||||
'' => array('prefix' => '', 'joiner' => ',', 'query' => false),
|
||||
'+' => array('prefix' => '', 'joiner' => ',', 'query' => false),
|
||||
'#' => array('prefix' => '#', 'joiner' => ',', 'query' => false),
|
||||
'.' => array('prefix' => '.', 'joiner' => '.', 'query' => false),
|
||||
'/' => array('prefix' => '/', 'joiner' => '/', 'query' => false),
|
||||
';' => array('prefix' => ';', 'joiner' => ';', 'query' => true),
|
||||
'?' => array('prefix' => '?', 'joiner' => '&', 'query' => true),
|
||||
'&' => array('prefix' => '&', 'joiner' => '&', 'query' => true)
|
||||
);
|
||||
private static $operatorHash = [
|
||||
'' => ['prefix' => '', 'joiner' => ',', 'query' => false],
|
||||
'+' => ['prefix' => '', 'joiner' => ',', 'query' => false],
|
||||
'#' => ['prefix' => '#', 'joiner' => ',', 'query' => false],
|
||||
'.' => ['prefix' => '.', 'joiner' => '.', 'query' => false],
|
||||
'/' => ['prefix' => '/', 'joiner' => '/', 'query' => false],
|
||||
';' => ['prefix' => ';', 'joiner' => ';', 'query' => true],
|
||||
'?' => ['prefix' => '?', 'joiner' => '&', 'query' => true],
|
||||
'&' => ['prefix' => '&', 'joiner' => '&', 'query' => true]
|
||||
];
|
||||
|
||||
/** @var array Delimiters */
|
||||
private static $delims = array(':', '/', '?', '#', '[', ']', '@', '!', '$',
|
||||
'&', '\'', '(', ')', '*', '+', ',', ';', '=');
|
||||
private static $delims = [':', '/', '?', '#', '[', ']', '@', '!', '$',
|
||||
'&', '\'', '(', ')', '*', '+', ',', ';', '='];
|
||||
|
||||
/** @var array Percent encoded delimiters */
|
||||
private static $delimsPct = array('%3A', '%2F', '%3F', '%23', '%5B', '%5D',
|
||||
private static $delimsPct = ['%3A', '%2F', '%3F', '%23', '%5B', '%5D',
|
||||
'%40', '%21', '%24', '%26', '%27', '%28', '%29', '%2A', '%2B', '%2C',
|
||||
'%3B', '%3D');
|
||||
'%3B', '%3D'];
|
||||
|
||||
public function expand($template, array $variables)
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ class UriTemplate
|
|||
*/
|
||||
private function parseExpression($expression)
|
||||
{
|
||||
$result = array();
|
||||
$result = [];
|
||||
|
||||
if (isset(self::$operatorHash[$expression[0]])) {
|
||||
$result['operator'] = $expression[0];
|
||||
|
@ -71,12 +71,12 @@ class UriTemplate
|
|||
|
||||
foreach (explode(',', $expression) as $value) {
|
||||
$value = trim($value);
|
||||
$varspec = array();
|
||||
$varspec = [];
|
||||
if ($colonPos = strpos($value, ':')) {
|
||||
$varspec['value'] = substr($value, 0, $colonPos);
|
||||
$varspec['modifier'] = ':';
|
||||
$varspec['position'] = (int) substr($value, $colonPos + 1);
|
||||
} elseif (substr($value, -1) == '*') {
|
||||
} elseif (substr($value, -1) === '*') {
|
||||
$varspec['modifier'] = '*';
|
||||
$varspec['value'] = substr($value, 0, -1);
|
||||
} else {
|
||||
|
@ -98,9 +98,9 @@ class UriTemplate
|
|||
*/
|
||||
private function expandMatch(array $matches)
|
||||
{
|
||||
static $rfc1738to3986 = array('+' => '%20', '%7e' => '~');
|
||||
static $rfc1738to3986 = ['+' => '%20', '%7e' => '~'];
|
||||
|
||||
$replacements = array();
|
||||
$replacements = [];
|
||||
$parsed = self::parseExpression($matches[1]);
|
||||
$prefix = self::$operatorHash[$parsed['operator']]['prefix'];
|
||||
$joiner = self::$operatorHash[$parsed['operator']]['joiner'];
|
||||
|
@ -119,7 +119,7 @@ class UriTemplate
|
|||
if (is_array($variable)) {
|
||||
|
||||
$isAssoc = $this->isAssoc($variable);
|
||||
$kvp = array();
|
||||
$kvp = [];
|
||||
foreach ($variable as $key => $var) {
|
||||
|
||||
if ($isAssoc) {
|
||||
|
@ -131,14 +131,14 @@ class UriTemplate
|
|||
|
||||
if (!$isNestedArray) {
|
||||
$var = rawurlencode($var);
|
||||
if ($parsed['operator'] == '+' ||
|
||||
$parsed['operator'] == '#'
|
||||
if ($parsed['operator'] === '+' ||
|
||||
$parsed['operator'] === '#'
|
||||
) {
|
||||
$var = $this->decodeReserved($var);
|
||||
}
|
||||
}
|
||||
|
||||
if ($value['modifier'] == '*') {
|
||||
if ($value['modifier'] === '*') {
|
||||
if ($isAssoc) {
|
||||
if ($isNestedArray) {
|
||||
// Nested arrays must allow for deeply nested
|
||||
|
@ -160,7 +160,7 @@ class UriTemplate
|
|||
|
||||
if (empty($variable)) {
|
||||
$actuallyUseQuery = false;
|
||||
} elseif ($value['modifier'] == '*') {
|
||||
} elseif ($value['modifier'] === '*') {
|
||||
$expanded = implode($joiner, $kvp);
|
||||
if ($isAssoc) {
|
||||
// Don't prepend the value name when using the explode
|
||||
|
@ -181,17 +181,17 @@ class UriTemplate
|
|||
}
|
||||
|
||||
} else {
|
||||
if ($value['modifier'] == ':') {
|
||||
if ($value['modifier'] === ':') {
|
||||
$variable = substr($variable, 0, $value['position']);
|
||||
}
|
||||
$expanded = rawurlencode($variable);
|
||||
if ($parsed['operator'] == '+' || $parsed['operator'] == '#') {
|
||||
if ($parsed['operator'] === '+' || $parsed['operator'] === '#') {
|
||||
$expanded = $this->decodeReserved($expanded);
|
||||
}
|
||||
}
|
||||
|
||||
if ($actuallyUseQuery) {
|
||||
if (!$expanded && $joiner != '&') {
|
||||
if (!$expanded && $joiner !== '&') {
|
||||
$expanded = $value['value'];
|
||||
} else {
|
||||
$expanded = $value['value'] . '=' . $expanded;
|
||||
|
|
53
vendor/guzzlehttp/guzzle/src/functions.php
vendored
53
vendor/guzzlehttp/guzzle/src/functions.php
vendored
|
@ -5,7 +5,6 @@ use GuzzleHttp\Handler\CurlHandler;
|
|||
use GuzzleHttp\Handler\CurlMultiHandler;
|
||||
use GuzzleHttp\Handler\Proxy;
|
||||
use GuzzleHttp\Handler\StreamHandler;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
/**
|
||||
* Expands a URI template
|
||||
|
@ -104,8 +103,12 @@ function debug_resource($value = null)
|
|||
function choose_handler()
|
||||
{
|
||||
$handler = null;
|
||||
if (extension_loaded('curl')) {
|
||||
if (function_exists('curl_multi_exec') && function_exists('curl_exec')) {
|
||||
$handler = Proxy::wrapSync(new CurlMultiHandler(), new CurlHandler());
|
||||
} elseif (function_exists('curl_exec')) {
|
||||
$handler = new CurlHandler();
|
||||
} elseif (function_exists('curl_multi_exec')) {
|
||||
$handler = new CurlMultiHandler();
|
||||
}
|
||||
|
||||
if (ini_get('allow_url_fopen')) {
|
||||
|
@ -278,3 +281,49 @@ function is_host_in_noproxy($host, array $noProxyArray)
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for json_decode that throws when an error occurs.
|
||||
*
|
||||
* @param string $json JSON data to parse
|
||||
* @param bool $assoc When true, returned objects will be converted
|
||||
* into associative arrays.
|
||||
* @param int $depth User specified recursion depth.
|
||||
* @param int $options Bitmask of JSON decode options.
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \InvalidArgumentException if the JSON cannot be decoded.
|
||||
* @link http://www.php.net/manual/en/function.json-decode.php
|
||||
*/
|
||||
function json_decode($json, $assoc = false, $depth = 512, $options = 0)
|
||||
{
|
||||
$data = \json_decode($json, $assoc, $depth, $options);
|
||||
if (JSON_ERROR_NONE !== json_last_error()) {
|
||||
throw new \InvalidArgumentException(
|
||||
'json_decode error: ' . json_last_error_msg());
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for JSON encoding that throws when an error occurs.
|
||||
*
|
||||
* @param mixed $value The value being encoded
|
||||
* @param int $options JSON encode option bitmask
|
||||
* @param int $depth Set the maximum depth. Must be greater than zero.
|
||||
*
|
||||
* @return string
|
||||
* @throws \InvalidArgumentException if the JSON cannot be encoded.
|
||||
* @link http://www.php.net/manual/en/function.json-encode.php
|
||||
*/
|
||||
function json_encode($value, $options = 0, $depth = 512)
|
||||
{
|
||||
$json = \json_encode($value, $options, $depth);
|
||||
if (JSON_ERROR_NONE !== json_last_error()) {
|
||||
throw new \InvalidArgumentException(
|
||||
'json_encode error: ' . json_last_error_msg());
|
||||
}
|
||||
|
||||
return $json;
|
||||
}
|
||||
|
|
Reference in a new issue