Commit 8b83aa08 authored by effulgentsia's avatar effulgentsia
Browse files

Issue #2493911 by dawehner, larowlan, damiankloip, hussainweb, jibran,...

Issue #2493911 by dawehner, larowlan, damiankloip, hussainweb, jibran, cilefen, benjy, iMiksu, mtdowling: Update guzzle, goutte and mink-goutte-driver to the latest release
parent cc34748c
......@@ -22,7 +22,7 @@
"twig/twig": "1.18.*",
"doctrine/common": "~2.4.2",
"doctrine/annotations": "1.2.*",
"guzzlehttp/guzzle": "~5.0",
"guzzlehttp/guzzle": "dev-master#1879fbe853b0c64d109e369c7aeff09849e62d1e",
"symfony-cmf/routing": "1.3.*",
"easyrdf/easyrdf": "0.9.*",
"phpunit/phpunit": "4.6.*",
......@@ -31,8 +31,8 @@
"stack/builder": "1.0.*",
"egulias/email-validator": "1.2.*",
"behat/mink": "~1.6",
"behat/mink-goutte-driver": "~1.1",
"fabpot/goutte": "^2.0.3",
"behat/mink-goutte-driver": "dev-master#cc5ce119b5a8e06662f634b35967aff0b0c7dfdd",
"fabpot/goutte": "~3.1",
"masterminds/html5": "~2.1",
"symfony/psr-http-message-bridge": "v0.2",
"zendframework/zend-diactoros": "1.1.0"
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "a842b991264d42a2f8c5cecbd82597b1",
"hash": "34a206d03b9060c6f1b2895c0517792c",
"packages": [
{
"name": "behat/mink",
......@@ -118,22 +118,22 @@
},
{
"name": "behat/mink-goutte-driver",
"version": "v1.1.0",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/minkphp/MinkGoutteDriver.git",
"reference": "2bf327b4166694ecaa8ae7f956cb6ae252ecf03e"
"reference": "cc5ce119b5a8e06662f634b35967aff0b0c7dfdd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/minkphp/MinkGoutteDriver/zipball/2bf327b4166694ecaa8ae7f956cb6ae252ecf03e",
"reference": "2bf327b4166694ecaa8ae7f956cb6ae252ecf03e",
"url": "https://api.github.com/repos/minkphp/MinkGoutteDriver/zipball/cc5ce119b5a8e06662f634b35967aff0b0c7dfdd",
"reference": "cc5ce119b5a8e06662f634b35967aff0b0c7dfdd",
"shasum": ""
},
"require": {
"behat/mink": "~1.6@dev",
"behat/mink-browserkit-driver": "~1.2@dev",
"fabpot/goutte": "~1.0.4|~2.0",
"fabpot/goutte": "~1.0.4|~2.0|~3.1",
"php": ">=5.3.1"
},
"type": "mink-driver",
......@@ -143,8 +143,8 @@
}
},
"autoload": {
"psr-0": {
"Behat\\Mink\\Driver": "src/"
"psr-4": {
"Behat\\Mink\\Driver\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
......@@ -166,7 +166,7 @@
"headless",
"testing"
],
"time": "2014-10-09 09:21:12"
"time": "2015-06-27 00:15:11"
},
{
"name": "doctrine/annotations",
......@@ -739,21 +739,21 @@
},
{
"name": "fabpot/goutte",
"version": "v2.0.3",
"version": "v3.1.0",
"source": {
"type": "git",
"url": "https://github.com/FriendsOfPHP/Goutte.git",
"reference": "65ab61eae03d670b93a9044ad2328eb81aa1bde5"
"reference": "d9a5a28782d30e9f4e20176caea58a1d459f2c71"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/FriendsOfPHP/Goutte/zipball/65ab61eae03d670b93a9044ad2328eb81aa1bde5",
"reference": "65ab61eae03d670b93a9044ad2328eb81aa1bde5",
"url": "https://api.github.com/repos/FriendsOfPHP/Goutte/zipball/d9a5a28782d30e9f4e20176caea58a1d459f2c71",
"reference": "d9a5a28782d30e9f4e20176caea58a1d459f2c71",
"shasum": ""
},
"require": {
"guzzlehttp/guzzle": ">=4,<6",
"php": ">=5.4.0",
"guzzlehttp/guzzle": "^6.0",
"php": ">=5.5.0",
"symfony/browser-kit": "~2.1",
"symfony/css-selector": "~2.1",
"symfony/dom-crawler": "~2.1"
......@@ -761,7 +761,7 @@
"type": "application",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
"dev-master": "3.1-dev"
}
},
"autoload": {
......@@ -784,25 +784,26 @@
"keywords": [
"scraper"
],
"time": "2014-11-28 09:48:17"
"time": "2015-06-24 16:11:31"
},
{
"name": "guzzlehttp/guzzle",
"version": "5.2.0",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "475b29ccd411f2fa8a408e64576418728c032cfa"
"reference": "1879fbe853b0c64d109e369c7aeff09849e62d1e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/475b29ccd411f2fa8a408e64576418728c032cfa",
"reference": "475b29ccd411f2fa8a408e64576418728c032cfa",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/1879fbe853b0c64d109e369c7aeff09849e62d1e",
"reference": "1879fbe853b0c64d109e369c7aeff09849e62d1e",
"shasum": ""
},
"require": {
"guzzlehttp/ringphp": "~1.0",
"php": ">=5.4.0"
"guzzlehttp/promises": "~1.0",
"guzzlehttp/psr7": "~1.1",
"php": ">=5.5.0"
},
"require-dev": {
"ext-curl": "*",
......@@ -812,10 +813,13 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.0-dev"
"dev-master": "6.0-dev"
}
},
"autoload": {
"files": [
"src/functions_include.php"
],
"psr-4": {
"GuzzleHttp\\": "src/"
}
......@@ -831,7 +835,7 @@
"homepage": "https://github.com/mtdowling"
}
],
"description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients",
"description": "Guzzle is a PHP HTTP client library",
"homepage": "http://guzzlephp.org/",
"keywords": [
"client",
......@@ -842,34 +846,28 @@
"rest",
"web service"
],
"time": "2015-01-28 01:03:29"
"time": "2015-07-10 20:04:21"
},
{
"name": "guzzlehttp/ringphp",
"version": "1.0.7",
"name": "guzzlehttp/promises",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/RingPHP.git",
"reference": "52d868f13570a9a56e5fce6614e0ec75d0f13ac2"
"url": "https://github.com/guzzle/promises.git",
"reference": "2ee5bc7f1a92efecc90da7f6711a53a7be26b5b7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/RingPHP/zipball/52d868f13570a9a56e5fce6614e0ec75d0f13ac2",
"reference": "52d868f13570a9a56e5fce6614e0ec75d0f13ac2",
"url": "https://api.github.com/repos/guzzle/promises/zipball/2ee5bc7f1a92efecc90da7f6711a53a7be26b5b7",
"reference": "2ee5bc7f1a92efecc90da7f6711a53a7be26b5b7",
"shasum": ""
},
"require": {
"guzzlehttp/streams": "~3.0",
"php": ">=5.4.0",
"react/promise": "~2.0"
"php": ">=5.5.0"
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "~4.0"
},
"suggest": {
"ext-curl": "Guzzle will use specific adapters if cURL is present"
},
"type": "library",
"extra": {
"branch-alias": {
......@@ -878,8 +876,11 @@
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Ring\\": "src/"
}
"GuzzleHttp\\Promise\\": "src/"
},
"files": [
"src/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
......@@ -892,25 +893,32 @@
"homepage": "https://github.com/mtdowling"
}
],
"description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.",
"time": "2015-03-30 01:43:20"
"description": "Guzzle promises library",
"keywords": [
"promise"
],
"time": "2015-06-24 16:16:25"
},
{
"name": "guzzlehttp/streams",
"version": "3.0.0",
"name": "guzzlehttp/psr7",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/streams.git",
"reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5"
"url": "https://github.com/guzzle/psr7.git",
"reference": "af0e1758de355eb113917ad79c3c0e3604bce4bd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/streams/zipball/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
"reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/af0e1758de355eb113917ad79c3c0e3604bce4bd",
"reference": "af0e1758de355eb113917ad79c3c0e3604bce4bd",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
"php": ">=5.4.0",
"psr/http-message": "~1.0"
},
"provide": {
"psr/http-message-implementation": "1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
......@@ -918,13 +926,16 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Stream\\": "src/"
}
"GuzzleHttp\\Psr7\\": "src/"
},
"files": [
"src/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
......@@ -937,13 +948,14 @@
"homepage": "https://github.com/mtdowling"
}
],
"description": "Provides a simple abstraction over streams of data",
"homepage": "http://guzzlephp.org/",
"description": "PSR-7 message implementation",
"keywords": [
"Guzzle",
"stream"
"http",
"message",
"stream",
"uri"
],
"time": "2014-10-12 19:18:40"
"time": "2015-06-24 19:55:15"
},
{
"name": "masterminds/html5",
......@@ -1625,50 +1637,6 @@
],
"time": "2012-12-21 11:40:51"
},
{
"name": "react/promise",
"version": "v2.2.0",
"source": {
"type": "git",
"url": "https://github.com/reactphp/promise.git",
"reference": "365fcee430dfa4ace1fbc75737ca60ceea7eeeef"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/reactphp/promise/zipball/365fcee430dfa4ace1fbc75737ca60ceea7eeeef",
"reference": "365fcee430dfa4ace1fbc75737ca60ceea7eeeef",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"autoload": {
"psr-4": {
"React\\Promise\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jan Sorgalla",
"email": "jsorgalla@googlemail.com"
}
],
"description": "A lightweight implementation of CommonJS Promises/A for PHP",
"time": "2014-12-30 13:32:42"
},
{
"name": "sdboyer/gliph",
"version": "0.1.8",
......@@ -3449,7 +3417,10 @@
"packages-dev": [],
"aliases": [],
"minimum-stability": "dev",
"stability-flags": [],
"stability-flags": {
"guzzlehttp/guzzle": 20,
"behat/mink-goutte-driver": 20
},
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
......
......@@ -2240,6 +2240,10 @@ function hook_validation_constraint_alter(array &$definitions) {
* - context_provider: Indicates a block context provider, used for example
* by block conditions. It has to implement
* \Drupal\Core\Plugin\Context\ContextProviderInterface.
* - http_client_middleware: Indicates that the service provides a guzzle
* middleware, see
* https://guzzle.readthedocs.org/en/latest/handlers-and-middleware.html for
* more information.
*
* Creating a tag for a service does not do anything on its own, but tags
* can be discovered or queried in a compiler pass when the container is built,
......
......@@ -379,10 +379,21 @@ services:
path.current:
class: Drupal\Core\Path\CurrentPathStack
arguments: ['@request_stack']
http_handler_stack:
class: GuzzleHttp\HandlerStack
public: false
factory: GuzzleHttp\HandlerStack::create
configurator: ['@http_handler_stack_configurator', configure]
http_handler_stack_configurator:
class: Drupal\Core\Http\HandlerStackConfigurator
public: false
arguments: ['@service_container']
http_client:
class: Drupal\Core\Http\Client
tags:
- { name: service_collector, tag: http_client_subscriber, call: attach }
class: GuzzleHttp\Client
factory: http_client_factory:fromOptions
http_client_factory:
class: Drupal\Core\Http\ClientFactory
arguments: ['@http_handler_stack']
theme.negotiator:
class: Drupal\Core\Theme\ThemeNegotiator
arguments: ['@access_check.theme']
......
......@@ -395,7 +395,7 @@ public static function state() {
/**
* Returns the default http client.
*
* @return \GuzzleHttp\ClientInterface
* @return \GuzzleHttp\Client
* A guzzle http client instance.
*/
public static function httpClient() {
......
......@@ -10,6 +10,7 @@
use Drupal\Core\Cache\Context\CacheContextsPass;
use Drupal\Core\Cache\ListCacheBinsPass;
use Drupal\Core\DependencyInjection\Compiler\BackendCompilerPass;
use Drupal\Core\DependencyInjection\Compiler\GuzzleMiddlewarePass;
use Drupal\Core\DependencyInjection\Compiler\ContextProvidersPass;
use Drupal\Core\DependencyInjection\Compiler\ProxyServicesPass;
use Drupal\Core\DependencyInjection\Compiler\RegisterLazyRouteEnhancers;
......@@ -75,6 +76,7 @@ public function register(ContainerBuilder $container) {
// Collect tagged handler services as method calls on consumer services.
$container->addCompilerPass(new TaggedHandlersPass());
$container->addCompilerPass(new RegisterStreamWrappersPass());
$container->addCompilerPass(new GuzzleMiddlewarePass());
// Add a compiler pass for registering event subscribers.
$container->addCompilerPass(new RegisterKernelListenersPass(), PassConfig::TYPE_AFTER_REMOVING);
......@@ -132,10 +134,10 @@ protected function registerTest(ContainerBuilder $container) {
if (!drupal_valid_test_ua()) {
return;
}
// Add the HTTP request subscriber to Guzzle.
// Add the HTTP request middleware to Guzzle.
$container
->register('test.http_client.request_subscriber', 'Drupal\Core\Test\EventSubscriber\HttpRequestSubscriber')
->addTag('http_client_subscriber');
->register('test.http_client.middleware', 'Drupal\Core\Test\HttpClientMiddleware\TestHttpClientMiddleware')
->addTag('http_client_middleware');
}
}
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\Compiler\GuzzleMiddlewarePass.
*/
namespace Drupal\Core\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class GuzzleMiddlewarePass implements CompilerPassInterface {
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container) {
$middleware_ids = array_keys($container->findTaggedServiceIds('http_client_middleware'));
$container->getDefinition('http_handler_stack_configurator')
->addArgument($middleware_ids);
}
}
......@@ -2,69 +2,66 @@
/**
* @file
* Contains \Drupal\Core\Http\Client.
* Contains \Drupal\Core\Http\ClientFactory.
*/
namespace Drupal\Core\Http;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Site\Settings;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Event\SubscriberInterface;
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
/**
* Drupal default HTTP client class.
* Helper class to construct a HTTP client with Drupal specific config.
*/
class Client extends GuzzleClient {
class ClientFactory {
/**
* {@inheritdoc}
* The handler stack.
*
* @var \GuzzleHttp\HandlerStack
*/
public function __construct(array $config = []) {
$default_config = array(
// Security consideration: we must not use the certificate authority
// file shipped with Guzzle because it can easily get outdated if a
// certificate authority is hacked. Instead, we rely on the certificate
// authority file provided by the operating system which is more likely
// going to be updated in a timely fashion. This overrides the default
// path to the pem file bundled with Guzzle.
'verify' => TRUE,
'timeout' => 30,
'headers' => array(
'User-Agent' => 'Drupal/' . \Drupal::VERSION . ' (+https://www.drupal.org/) ' . static::getDefaultUserAgent(),
),
);
// The entire config array is merged/configurable to allow Guzzle client
// options outside of 'defaults' to be changed, such as 'adapter', or
// 'message_factory'.
$config = NestedArray::mergeDeep(array('defaults' => $default_config), $config, Settings::get('http_client_config', array()));
parent::__construct($config);
}
protected $stack;
/**
* Attaches an event subscriber.
* Constructs a new ClientFactory instance.
*
* @param \GuzzleHttp\Event\SubscriberInterface $subscriber
* The subscriber to attach.
*
* @see \GuzzleHttp\Event\Emitter::attach()
* @param \GuzzleHttp\HandlerStack $stack
* The handler stack.
*/
public function attach(SubscriberInterface $subscriber) {
$this->getEmitter()->attach($subscriber);
public function __construct(HandlerStack $stack) {
$this->stack = $stack;
}
/**
* Detaches an event subscriber.
* Constructs a new client object from some configuration.
*
* @param \GuzzleHttp\Event\SubscriberInterface $subscriber
* The subscriber to detach.
* @param array $config
* The config for the client.
*
* @see \GuzzleHttp\Event\Emitter::detach()
* @return \GuzzleHttp\Client
* The HTTP client.
*/
public function detach(SubscriberInterface $subscriber) {
$this->getEmitter()->detach($subscriber);
public function fromOptions(array $config = []) {
$default_config = [
// Security consideration: we must not use the certificate authority
// file shipped with Guzzle because it can easily get outdated if a
// certificate authority is hacked. Instead, we rely on the certificate
// authority file provided by the operating system which is more likely
// going to be updated in a timely fashion. This overrides the default
// path to the pem file bundled with Guzzle.
'verify' => TRUE,
'timeout' => 30,
'headers' => [
'User-Agent' => 'Drupal/' . \Drupal::VERSION . ' (+https://www.drupal.org/) ' . \GuzzleHttp\default_user_agent(),
],
'handler' => $this->stack,
];
$config = NestedArray::mergeDeep($default_config, Settings::get('http_client_config', []), $config);
return new Client($config);
}
}
<?php
/**
* @file
* Contains \Drupal\Core\Http\HandlerStackConfigurator.
*/
namespace Drupal\Core\Http;
use GuzzleHttp\HandlerStack;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Defines a class for configuring middlewares on the http handler stack.
*
* The http_client service requires a handler stack to perform http requests.
* This is provided by the http_handler_stack service. Modules wishing to add
* additional middlewares to the handler stack can create services and tag them
* as http_client_middleware. Each service must contain an __invoke method that
* returns a closure which will serve as the middleware.
*
* @see https://guzzle.readthedocs.org/en/latest/handlers-and-middleware.html
*
* @see \Drupal\Core\Http\Client
* @see \Drupal\Core\Test\HttpClientMiddleware\TestHttpClientMiddleware
*/
class HandlerStackConfigurator {
/**
* Array of middlewares to add to the handler stack.
*
* @var callable[]
*/
protected $middlewares = NULL;
/**
* A list of used middleware service IDs.
*
* @var string[]
*/
protected $middlewareIds = [];
/**
* The service container.
*
* @var \Symfony\Component\DependencyInjection\ContainerInterface
*/
protected $container;
/**
* Contructs a new HandlerStackConfigurator object.
*
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* The service container.
* @param string[] $middleware_ids
* The middleware IDs.
*/
public function __construct(ContainerInterface $container, array $middleware_ids) {
$this->middlewareIds = $middleware_ids;
$this->container = $container;