Commit fa9b7ac8 authored by catch's avatar catch

Issue #2348365 by larowlan | mtdowling: Update to Guzzle 5.

parent 88dcf91f
......@@ -4,7 +4,7 @@
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "f51bcf6e79129718cf410ac81b6449f1",
"hash": "838f4566f4f537d5f71fa46b66f263b0",
"packages": [
{
"name": "doctrine/annotations",
......@@ -568,21 +568,20 @@
},
{
"name": "guzzlehttp/guzzle",
"version": "4.1.8",
"version": "5.0.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "e196b8f44f9492a11261ea8f7b9724613a198daf"
"reference": "28b51e11237f25cdb0efaea8e45af26007831aa9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/e196b8f44f9492a11261ea8f7b9724613a198daf",
"reference": "e196b8f44f9492a11261ea8f7b9724613a198daf",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/28b51e11237f25cdb0efaea8e45af26007831aa9",
"reference": "28b51e11237f25cdb0efaea8e45af26007831aa9",
"shasum": ""
},
"require": {
"ext-json": "*",
"guzzlehttp/streams": "~1.4",
"guzzlehttp/ringphp": "~1.0",
"php": ">=5.4.0"
},
"require-dev": {
......@@ -590,22 +589,16 @@
"phpunit/phpunit": "~4.0",
"psr/log": "~1.0"
},
"suggest": {
"ext-curl": "Guzzle will use specific adapters if cURL is present"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.1-dev"
"dev-ring": "5.0-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\": "src/"
},
"files": [
"src/functions.php"
]
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
......@@ -629,20 +622,70 @@
"rest",
"web service"
],
"time": "2014-08-14 20:29:51"
"time": "2014-10-13 03:05:51"
},
{
"name": "guzzlehttp/ringphp",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/RingPHP.git",
"reference": "9e44b565d726d9614cd970319e6eea70ee15bff3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/RingPHP/zipball/9e44b565d726d9614cd970319e6eea70ee15bff3",
"reference": "9e44b565d726d9614cd970319e6eea70ee15bff3",
"shasum": ""
},
"require": {
"guzzlehttp/streams": "~3.0",
"php": ">=5.4.0",
"react/promise": "~2.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": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Ring\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"time": "2014-10-13 00:59:38"
},
{
"name": "guzzlehttp/streams",
"version": "1.5.1",
"version": "3.0.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/streams.git",
"reference": "fb0d1ee29987c2bdc59867bffaade6fc88c2675f"
"reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/streams/zipball/fb0d1ee29987c2bdc59867bffaade6fc88c2675f",
"reference": "fb0d1ee29987c2bdc59867bffaade6fc88c2675f",
"url": "https://api.github.com/repos/guzzle/streams/zipball/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
"reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
"shasum": ""
},
"require": {
......@@ -654,16 +697,13 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.5-dev"
"dev-master": "3.0-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Stream\\": "src/"
},
"files": [
"src/functions.php"
]
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
......@@ -676,13 +716,13 @@
"homepage": "https://github.com/mtdowling"
}
],
"description": "Provides a simple abstraction over streams of data (Guzzle 4+)",
"description": "Provides a simple abstraction over streams of data",
"homepage": "http://guzzlephp.org/",
"keywords": [
"Guzzle",
"stream"
],
"time": "2014-08-10 23:57:01"
"time": "2014-10-12 19:18:40"
},
{
"name": "mikey179/vfsStream",
......@@ -1136,6 +1176,50 @@
],
"time": "2012-12-21 11:40:51"
},
{
"name": "react/promise",
"version": "v2.1.0",
"source": {
"type": "git",
"url": "https://github.com/reactphp/promise.git",
"reference": "937b04f1b0ee8f6d180e75a0830aac778ca4bcd6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/reactphp/promise/zipball/937b04f1b0ee8f6d180e75a0830aac778ca4bcd6",
"reference": "937b04f1b0ee8f6d180e75a0830aac778ca4bcd6",
"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.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-10-15 20:05:57"
},
{
"name": "sdboyer/gliph",
"version": "0.1.8",
......
......@@ -8,6 +8,7 @@
namespace Drupal\update;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\RequestException;
......@@ -16,6 +17,8 @@
*/
class UpdateFetcher implements UpdateFetcherInterface {
use DependencySerializationTrait;
/**
* URL to check for updates, if a given project doesn't define its own.
*/
......@@ -63,9 +66,9 @@ public function fetchProjectData(array $project, $site_key = '') {
$url = $this->buildFetchUrl($project, $site_key);
$data = '';
try {
$data = $this->httpClient
$data = (string) $this->httpClient
->get($url, array('headers' => array('Accept' => 'text/xml')))
->getBody(TRUE);
->getBody();
}
catch (RequestException $exception) {
watchdog_exception('update', $exception);
......
......@@ -6,7 +6,6 @@
$baseDir = dirname(dirname($vendorDir));
return array(
$vendorDir . '/guzzlehttp/streams/src/functions.php',
$vendorDir . '/guzzlehttp/guzzle/src/functions.php',
$vendorDir . '/react/promise/src/functions.php',
$baseDir . '/core/lib/Drupal.php',
);
......@@ -6,7 +6,9 @@
$baseDir = dirname(dirname($vendorDir));
return array(
'React\\Promise\\' => array($vendorDir . '/react/promise/src'),
'GuzzleHttp\\Stream\\' => array($vendorDir . '/guzzlehttp/streams/src'),
'GuzzleHttp\\Ring\\' => array($vendorDir . '/guzzlehttp/ringphp/src'),
'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
'Drupal\\Driver\\' => array($baseDir . '/drivers/lib/Drupal/Driver'),
'Drupal\\Core\\' => array($baseDir . '/core/lib/Drupal/Core'),
......
This diff is collapsed.
......@@ -3,7 +3,7 @@ composer.phar
composer.lock
composer-test.lock
vendor/
build/
build/artifacts/
artifacts/
docs/_build
docs/*.pyc
......
......@@ -21,3 +21,19 @@ matrix:
allow_failures:
- php: hhvm
fast_finish: true
before_deploy:
- make package
deploy:
provider: releases
api_key:
secure: UpypqlYgsU68QT/x40YzhHXvzWjFwCNo9d+G8KAdm7U9+blFfcWhV1aMdzugvPMl6woXgvJj7qHq5tAL4v6oswCORhpSBfLgOQVFaica5LiHsvWlAedOhxGmnJqMTwuepjBCxXhs3+I8Kof1n4oUL9gKytXjOVCX/f7XU1HiinU=
file:
- build/artifacts/guzzle.phar
- build/artifacts/guzzle.zip
on:
repo: guzzle/guzzle
tags: true
all_branches: true
php: 5.4
CHANGELOG
=========
5.0.0 (2014-10-12)
------------------
Adding support for non-blocking responses and some minor API cleanup.
### New Features
* Added support for non-blocking responses based on `guzzlehttp/guzzle-ring`.
* Added a public API for creating a default HTTP adapter.
* Updated the redirect plugin to be non-blocking so that redirects are sent
concurrently. Other plugins like this can now be updated to be non-blocking.
* Added a "progress" event so that you can get upload and download progress
events.
* Added `GuzzleHttp\Pool` which implements FutureInterface and transfers
requests concurrently using a capped pool size as efficiently as possible.
* Added `hasListeners()` to EmitterInterface.
* Removed `GuzzleHttp\ClientInterface::sendAll` and marked
`GuzzleHttp\Client::sendAll` as deprecated (it's still there, just not the
recommended way).
### Breaking changes
The breaking changes in this release are relatively minor. The biggest thing to
look out for is that request and response objects no longer implement fluent
interfaces.
* Removed the fluent interfaces (i.e., ``return $this``) from requests,
responses, ``GuzzleHttp\Collection``, ``GuzzleHttp\Url``,
``GuzzleHttp\Query``, ``GuzzleHttp\Post\PostBody``, and
``GuzzleHttp\Cookie\SetCookie``. This blog post provides a good outline of
why I did this: http://ocramius.github.io/blog/fluent-interfaces-are-evil/.
This also makes the Guzzle message interfaces compatible with the current
PSR-7 message proposal.
* Removed "functions.php", so that Guzzle is truly PSR-4 compliant. Except
for the HTTP request functions from function.php, these functions are now
implemented in `GuzzleHttp\Utils` using camelCase. `GuzzleHttp\json_decode`
moved to `GuzzleHttp\Utils::jsonDecode`. `GuzzleHttp\get_path` moved to
`GuzzleHttp\Utils::getPath`. `GuzzleHttp\set_path` moved to
`GuzzleHttp\Utils::setPath`. `GuzzleHttp\batch` should now be
`GuzzleHttp\Pool::batch`, which returns a bjectStorage`. Using functions.php
caused problems for many users: they aren't PSR-4 compliant, require an
explicit include, and needed an if-guard to ensure that the functions are not
declared multiple times.
* Rewrote adapter layer.
* Removing all classes from `GuzzleHttp\Adapter`, these are now
implemented as callables that are stored in `GuzzleHttp\Ring\Client`.
* Removed the concept of "parallel adapters". Sending requests serially or
concurrently is now handled using a single adapter.
* Moved `GuzzleHttp\Adapter\Transaction` to `GuzzleHttp\Transaction`. The
Transaction object now exposes the request, response, and client as public
properties. The getters and setters have been removed.
* Removed the "headers" event. This event was only useful for changing the
body a response once the headers of the response were known. You can implement
a similar behavior in a number of ways. One example might be to use a
FnStream that has access to the transaction being sent. For example, when the
first byte is written, you could check if the response headers match your
expectations, and if so, change the actual stream body that is being
written to.
* Removed the `asArray` parameter from
`GuzzleHttp\Message\MessageInterface::getHeader`. If you want to get a header
value as an array, then use the newly added ``getHeaderAsArray()`` method of
``MessageInterface``. This change makes the Guzzle interfaces compatible with
the PSR-7 interfaces.
* ``GuzzleHttp\Message\MessageFactory`` no longer allows subclasses to add
custom request options using double-dispatch (this was an implementation
detail). Instead, you should now provide an associative array to the
constructor which is a mapping of the request option name mapping to a
function that applies the option value to a request.
* Removed the concept of "throwImmediately" from exceptions and error events.
This control mechanism was used to stop a transfer of concurrent requests
from completing. This can now be handled by throwing the exception or by
cancelling a pool of requests or each outstanding future request individually.
* Updated to "GuzzleHttp\Streams" 3.0.
* `GuzzleHttp\Stream\StreamInterface::getContents()` no longer accepts a
`maxLen` parameter. This update makes the Guzzle streams project
compatible with the current PSR-7 proposal.
* ``GuzzleHttp\Stream\Stream::__construct``,
``GuzzleHttp\Stream\Stream::factory``, and
``GuzzleHttp\Stream\Utils::create`` no longer accept a size in the second
argument. They now accept an associative array of options, including the
"size" key and "metadata" key which can be used to provide custom metadata.
4.2.2 (2014-09-08)
------------------
* Fixed a memory leak in the CurlAdapter when reusing cURL handles.
* No longer using `request_fulluri` in stream adapter proxies.
* Relative redirects are now based on the last response, not the first response.
4.2.1 (2014-08-19)
------------------
* Ensuring that the StreamAdapter does not always add a Content-Type header
* Adding automated github releases with a phar and zip
4.2.0 (2014-08-17)
------------------
* Now merging in default options using a case-insensitive comparison.
Closes https://github.com/guzzle/guzzle/issues/767
* Added the ability to automatically decode `Content-Encoding` response bodies
using the `decode_content` request option. This is set to `true` by default
to decode the response body if it comes over the wire with a
`Content-Encoding`. Set this value to `false` to disable decoding the
response content, and pass a string to provide a request `Accept-Encoding`
header and turn on automatic response decoding. This feature now allows you
to pass an `Accept-Encoding` header in the headers of a request but still
disable automatic response decoding.
Closes https://github.com/guzzle/guzzle/issues/764
* Added the ability to throw an exception immediately when transferring
requests in parallel. Closes https://github.com/guzzle/guzzle/issues/760
* Updating guzzlehttp/streams dependency to ~2.1
* No longer utilizing the now deprecated namespaced methods from the stream
package.
4.1.8 (2014-08-14)
------------------
......
all: clean coverage docs
start-server:
@ps aux | grep 'node tests/server.js' | grep -v grep > /dev/null \
|| node tests/server.js &> /dev/null &
cd vendor/guzzlehttp/ringphp && make start-server
stop-server:
@PID=$(shell ps axo pid,command | grep 'tests/server.js' | grep -v grep | cut -f 1 -d " ") && \
[ -n "$$PID" ] && \
kill $$PID || \
true
cd vendor/guzzlehttp/ringphp && make stop-server
test: start-server
vendor/bin/phpunit
......@@ -30,8 +26,25 @@ docs:
view-docs:
open docs/_build/html/index.html
tag:
$(if $(TAG),,$(error TAG is not defined. Pass via "make tag TAG=4.2.1"))
@echo Tagging $(TAG)
chag update -m '$(TAG) ()'
sed -i '' -e "s/VERSION = '.*'/VERSION = '$(TAG)'/" src/ClientInterface.php
php -l src/ClientInterface.php
git add -A
git commit -m '$(TAG) release'
chag tag
perf: start-server
php tests/perf.php
$(MAKE) stop-server
.PHONY: docs
package: burgomaster
php build/packager.php
burgomaster:
mkdir -p build/artifacts
curl -s https://raw.githubusercontent.com/mtdowling/Burgomaster/0.0.1/src/Burgomaster.php > build/artifacts/Burgomaster.php
.PHONY: docs burgomaster
......@@ -3,38 +3,44 @@ Guzzle, PHP HTTP client and webservice framework
[![Build Status](https://secure.travis-ci.org/guzzle/guzzle.png?branch=master)](http://travis-ci.org/guzzle/guzzle)
Guzzle is a PHP HTTP client that makes it easy to work with HTTP/1.1 and takes
the pain out of consuming web services.
Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and
trivial to integrate with web services.
- Manages things like persistent connections, represents query strings as
collections, simplifies sending streaming POST requests with fields and
files, and abstracts away the underlying HTTP transport layer.
- Can send both synchronous and asynchronous requests using the same interface
without requiring a dependency on a specific event loop.
- Pluggable HTTP adapters allows Guzzle to integrate with any method you choose
for sending HTTP requests over the wire (e.g., cURL, sockets, PHP's stream
wrapper, non-blocking event loops like ReactPHP.
- Guzzle makes it so that you no longer need to fool around with cURL options,
stream contexts, or sockets.
```php
$client = new GuzzleHttp\Client();
$response = $client->get('http://guzzlephp.org');
$res = $client->get('https://api.github.com/user', ['auth' => ['user', 'pass']]);
echo $res->getStatusCode();
// 200
// "200"
echo $res->getHeader('content-type');
// 'application/json; charset=utf8'
echo $res->getBody();
// {"type":"User"...'
var_export($res->json());
// Outputs the JSON decoded data
```
- Pluggable HTTP adapters that can send requests serially or in parallel
- Doesn't require cURL, but uses cURL by default
- Streams data for both uploads and downloads
- Provides event hooks & plugins for cookies, caching, logging, OAuth, mocks,
etc.
- Keep-Alive & connection pooling
- SSL Verification
- Automatic decompression of response bodies
- Streaming multipart file uploads
- Connection timeouts
// Send an asynchronous request.
$req = $client->createRequest('GET', 'http://httpbin.org', ['future' => true]);
$client->send($req)->then(function ($response) {
echo 'I completed! ' . $response;
});
```
Get more information and answers with the
[Documentation](http://guzzlephp.org/),
[Forums](https://groups.google.com/forum/?hl=en#!forum/guzzle),
and IRC ([#guzzlephp](irc://irc.freenode.net/#guzzlephp) @ irc.freenode.net).
and [Gitter](https://gitter.im/guzzle/guzzle).
### Installing via Composer
......@@ -51,7 +57,7 @@ Next, update your project's composer.json file to include Guzzle:
```javascript
{
"require": {
"guzzlehttp/guzzle": "~4.0"
"guzzlehttp/guzzle": "~5.0"
}
}
```
......
Guzzle Upgrade Guide
====================
4.x to 5.0
----------
## Rewritten Adapter Layer
Guzzle now uses `RingPHP <http://ringphp.readthedocs.org/en/latest/>`_ to send
HTTP requests. The `adapter` option in a `GuzzleHttp\Client` constructor
is still supported, but it has now been renamed to `handler`. Instead of
passing a `GuzzleHttp\Adapter\AdapterInterface`, you must now pass a PHP
`callable` that follows the RingPHP specification.
## Removed Fluent Interfaces
`Fluent interfaces were removed <http://ocramius.github.io/blog/fluent-interfaces-are-evil/>`_
from the following classes:
- `GuzzleHttp\Collection`
- `GuzzleHttp\Url`
- `GuzzleHttp\Query`
- `GuzzleHttp\Post\PostBody`
- `GuzzleHttp\Cookie\SetCookie`
## Removed functions.php
Removed "functions.php", so that Guzzle is truly PSR-4 compliant. The following
functions can be used as replacements.
- `GuzzleHttp\json_decode` -> `GuzzleHttp\Utils::jsonDecode`
- `GuzzleHttp\get_path` -> `GuzzleHttp\Utils::getPath`
- `GuzzleHttp\Utils::setPath` -> `GuzzleHttp\set_path`
- `GuzzleHttp\Pool::batch` -> `GuzzleHttp\batch`. This function is, however,
deprecated in favor of using `GuzzleHttp\Pool::batch()`.
The "procedural" global client has been removed with no replacement (e.g.,
`GuzzleHttp\get()`, `GuzzleHttp\post()`, etc.). Use a `GuzzleHttl\Client`
object as a replacement.
## `throwImmediately` has been removed
The concept of "throwImmediately" has been removed from exceptions and error
events. This control mechanism was used to stop a transfer of concurrent
requests from completing. This can now be handled by throwing the exception or
by cancelling a pool of requests or each outstanding future request
individually.
## headers event has been removed
Removed the "headers" event. This event was only useful for changing the
body a response once the headers of the response were known. You can implement
a similar behavior in a number of ways. One example might be to use a
FnStream that has access to the transaction being sent. For example, when the
first byte is written, you could check if the response headers match your
expectations, and if so, change the actual stream body that is being
written to.
## Updates to HTTP Messages
Removed the `asArray` parameter from
`GuzzleHttp\Message\MessageInterface::getHeader`. If you want to get a header
value as an array, then use the newly added `getHeaderAsArray()` method of
`MessageInterface`. This change makes the Guzzle interfaces compatible with