Commit 45f2030a authored by webchick's avatar webchick

Revert "Issue #2369107 by lussoluca: Update Guzzle to 5.0.3."

Temporary revert; CMF 1.3 is also ready and is a bigger PITA to re-roll.

This reverts commit d806a9bb.
parent 090d5570
......@@ -568,16 +568,16 @@
},
{
"name": "guzzlehttp/guzzle",
"version": "5.0.3",
"version": "5.0.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "6c72627de1d66832e4270e36e56acdb0d1d8f282"
"reference": "28b51e11237f25cdb0efaea8e45af26007831aa9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/6c72627de1d66832e4270e36e56acdb0d1d8f282",
"reference": "6c72627de1d66832e4270e36e56acdb0d1d8f282",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/28b51e11237f25cdb0efaea8e45af26007831aa9",
"reference": "28b51e11237f25cdb0efaea8e45af26007831aa9",
"shasum": ""
},
"require": {
......@@ -592,7 +592,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.0-dev"
"dev-ring": "5.0-dev"
}
},
"autoload": {
......@@ -622,7 +622,7 @@
"rest",
"web service"
],
"time": "2014-11-04 07:09:15"
"time": "2014-10-13 03:05:51"
},
{
"name": "guzzlehttp/ringphp",
......
......@@ -2528,6 +2528,66 @@
}
]
},
{
"name": "guzzlehttp/guzzle",
"version": "5.0.0",
"version_normalized": "5.0.0.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "28b51e11237f25cdb0efaea8e45af26007831aa9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/28b51e11237f25cdb0efaea8e45af26007831aa9",
"reference": "28b51e11237f25cdb0efaea8e45af26007831aa9",
"shasum": ""
},
"require": {
"guzzlehttp/ringphp": "~1.0",
"php": ">=5.4.0"
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "~4.0",
"psr/log": "~1.0"
},
"time": "2014-10-13 03:05:51",
"type": "library",
"extra": {
"branch-alias": {
"dev-ring": "5.0-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"GuzzleHttp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients",
"homepage": "http://guzzlephp.org/",
"keywords": [
"client",
"curl",
"framework",
"http",
"http client",
"rest",
"web service"
]
},
{
"name": "twig/twig",
"version": "v1.16.2",
......@@ -2586,65 +2646,5 @@
"keywords": [
"templating"
]
},
{
"name": "guzzlehttp/guzzle",
"version": "5.0.3",
"version_normalized": "5.0.3.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "6c72627de1d66832e4270e36e56acdb0d1d8f282"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/6c72627de1d66832e4270e36e56acdb0d1d8f282",
"reference": "6c72627de1d66832e4270e36e56acdb0d1d8f282",
"shasum": ""
},
"require": {
"guzzlehttp/ringphp": "~1.0",
"php": ">=5.4.0"
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "~4.0",
"psr/log": "~1.0"
},
"time": "2014-11-04 07:09:15",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.0-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"GuzzleHttp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients",
"homepage": "http://guzzlephp.org/",
"keywords": [
"client",
"curl",
"framework",
"http",
"http client",
"rest",
"web service"
]
}
]
This diff is collapsed.
......@@ -29,7 +29,7 @@ view-docs:
tag:
$(if $(TAG),,$(error TAG is not defined. Pass via "make tag TAG=4.2.1"))
@echo Tagging $(TAG)
chag update $(TAG)
chag update -m '$(TAG) ()'
sed -i '' -e "s/VERSION = '.*'/VERSION = '$(TAG)'/" src/ClientInterface.php
php -l src/ClientInterface.php
git add -A
......@@ -45,6 +45,6 @@ package: burgomaster
burgomaster:
mkdir -p build/artifacts
curl -s https://raw.githubusercontent.com/mtdowling/Burgomaster/0.0.2/src/Burgomaster.php > build/artifacts/Burgomaster.php
curl -s https://raw.githubusercontent.com/mtdowling/Burgomaster/0.0.1/src/Burgomaster.php > build/artifacts/Burgomaster.php
.PHONY: docs burgomaster
......@@ -52,10 +52,14 @@ The recommended way to install Guzzle is through
curl -sS https://getcomposer.org/installer | php
```
Next, run the Composer command to install the latest stable version of Guzzle:
Next, update your project's composer.json file to include Guzzle:
```bash
composer require guzzlehttp/guzzle
```javascript
{
"require": {
"guzzlehttp/guzzle": "~5.0"
}
}
```
After installing, you need to require Composer's autoloader:
......
......@@ -33,7 +33,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "5.0-dev"
"dev-ring": "5.0-dev"
}
}
}
......@@ -202,12 +202,12 @@ priority of the listener (as shown in the ``before`` listener in the example).
];
}
public function onBefore(BeforeEvent $event, $name)
public function onBefore(BeforeEvent $event, $name, EmitterInterface $emitter)
{
echo 'Before!';
}
public function onComplete(CompleteEvent $event, $name)
public function onComplete(CompleteEvent $event, $name, EmitterInterface $emitter)
{
echo 'Complete!';
}
......
......@@ -97,7 +97,7 @@ exception.
.. code-block:: php
$request = $client->createRequest('GET', ['future' => true]);
$request = $client->createRequest('GET', ['future' => true']);
$client->send($request)->then(function ($response) {
echo 'Got a response! ' . $response;
});
......@@ -107,7 +107,7 @@ of a response.
.. code-block:: php
$request = $client->createRequest('GET', ['future' => true]);
$request = $client->createRequest('GET', ['future' => true']);
$futureResponse = $client->send($request);
$futureResponse->wait();
......
......@@ -38,6 +38,6 @@ up to the RingPHP project using a very simple bridge class
Creating a handler
------------------
See the `RingPHP <http://ringphp.readthedocs.org>`_ project
See the `RingPHP <http://guzzle-ring.readthedocs.org>`_ project
documentation for more information on creating custom handlers that can be
used with Guzzle clients.
......@@ -11,7 +11,7 @@
*/
interface ClientInterface extends HasEmitterInterface
{
const VERSION = '5.0.3';
const VERSION = '5.0.0';
/**
* Create and return a new {@see RequestInterface} object.
......
......@@ -2,7 +2,6 @@
namespace GuzzleHttp\Event;
use GuzzleHttp\Message\ResponseInterface;
use GuzzleHttp\Ring\Future\FutureInterface;
/**
* Event that contains transfer statistics, and can be intercepted.
......@@ -28,23 +27,13 @@ public function getTransferInfo($name = null)
}
/**
* Returns true/false if a response is available.
*
* @return bool
*/
public function hasResponse()
{
return !($this->transaction->response instanceof FutureInterface);
}
/**
* Get the response.
* Get the response
*
* @return ResponseInterface|null
*/
public function getResponse()
{
return $this->hasResponse() ? $this->transaction->response : null;
return $this->transaction->response;
}
/**
......
......@@ -70,7 +70,7 @@ public static function create(
return new self('Error completing request', $request, null, $previous);
}
$level = floor($response->getStatusCode() / 100);
$level = $response->getStatusCode()[0];
if ($level == '4') {
$label = 'Client error response';
$className = __NAMESPACE__ . '\\ClientException';
......
......@@ -83,7 +83,7 @@ class Response extends AbstractMessage implements ResponseInterface
private $effectiveUrl;
/**
* @param int|string $statusCode The response status code (e.g. 200)
* @param string $statusCode The response status code (e.g. 200)
* @param array $headers The response headers
* @param StreamInterface $body The body of the response
* @param array $options Response message options
......@@ -96,7 +96,7 @@ public function __construct(
StreamInterface $body = null,
array $options = []
) {
$this->statusCode = (int) $statusCode;
$this->statusCode = (string) $statusCode;
$this->handleOptions($options);
// Assume a reason phrase if one was not applied as an option
......@@ -122,7 +122,7 @@ public function getStatusCode()
public function setStatusCode($code)
{
return $this->statusCode = (int) $code;
return $this->statusCode = $code;
}
public function getReasonPhrase()
......
......@@ -12,14 +12,14 @@
* The Status-Code is a 3-digit integer result code of the server's attempt
* to understand and satisfy the request.
*
* @return int Status code.
* @return integer Status code.
*/
public function getStatusCode();
/**
* Sets the status code of this response.
*
* @param int $code The 3-digit integer result code to set.
* @param integer $code The 3-digit integer result code to set.
*/
public function setStatusCode($code);
......
......@@ -127,22 +127,6 @@ public static function batch(
return new BatchResults($hash);
}
/**
* Creates a Pool and immediately sends the requests.
*
* @param ClientInterface $client Client used to send the requests
* @param array|\Iterator $requests Requests to send in parallel
* @param array $options Passes through the options available in
* {@see GuzzleHttp\Pool::__construct}
*/
public static function send(
ClientInterface $client,
$requests,
array $options = []
) {
(new self($client, $requests, $options))->wait();
}
public function wait()
{
if ($this->isRealized) {
......
......@@ -101,8 +101,8 @@ protected function createStream(array $fields, array $files)
$stream->addStream(Stream::factory("\r\n"));
}
// Add the trailing boundary with CRLF
$stream->addStream(Stream::factory("--{$this->boundary}--\r\n"));
// Add the trailing boundary
$stream->addStream(Stream::factory("--{$this->boundary}--"));
return $stream;
}
......
......@@ -38,11 +38,8 @@ public function applyRequestHeaders(RequestInterface $request)
'Content-Type',
'multipart/form-data; boundary=' . $this->getBody()->getBoundary()
);
} elseif ($this->fields && !$request->hasHeader('Content-Type')) {
$request->setHeader(
'Content-Type',
'application/x-www-form-urlencoded'
);
} elseif ($this->fields) {
$request->setHeader('Content-Type', 'application/x-www-form-urlencoded');
}
if ($size = $this->getSize()) {
......
......@@ -9,8 +9,9 @@ class Query extends Collection
const RFC3986 = 'RFC3986';
const RFC1738 = 'RFC1738';
/** @var callable Encoding function */
private $encoding = 'rawurlencode';
/** @var bool URL encode fields and values */
private $encoding = self::RFC3986;
/** @var callable */
private $aggregator;
......@@ -74,16 +75,27 @@ public function __toString()
$result = '';
$aggregator = $this->aggregator;
$encoder = $this->encoding;
foreach ($aggregator($this->data) as $key => $values) {
foreach ($values as $value) {
if ($result) {
$result .= '&';
}
$result .= $encoder($key);
if ($value !== null) {
$result .= '=' . $encoder($value);
if ($this->encoding == self::RFC1738) {
$result .= urlencode($key);
if ($value !== null) {
$result .= '=' . urlencode($value);
}
} elseif ($this->encoding == self::RFC3986) {
$result .= rawurlencode($key);
if ($value !== null) {
$result .= '=' . rawurlencode($value);
}
} else {
$result .= $key;
if ($value !== null) {
$result .= '=' . $value;
}
}
}
}
......@@ -117,18 +129,10 @@ public function setAggregator(callable $aggregator)
*/
public function setEncodingType($type)
{
switch ($type) {
case self::RFC3986:
$this->encoding = 'rawurlencode';
break;
case self::RFC1738:
$this->encoding = 'urlencode';
break;
case false:
$this->encoding = function ($v) { return $v; };
break;
default:
throw new \InvalidArgumentException('Invalid URL encoding type');
if ($type === false || $type === self::RFC1738 || $type === self::RFC3986) {
$this->encoding = $type;
} else {
throw new \InvalidArgumentException('Invalid URL encoding type');
}
}
......
......@@ -87,8 +87,8 @@ public static function completeRingResponse(
callable $fsm
) {
$trans->state = 'complete';
$trans->transferInfo = isset($response['transfer_stats'])
? $response['transfer_stats'] : [];
$trans->transferInfo = isset($response['transfer_info'])
? $response['transfer_info'] : [];
if (!empty($response['status'])) {
$options = [];
......
<?php
namespace GuzzleHttp;
use GuzzleHttp\Ring\Core;
/**
* Parses and generates URLs based on URL parts
*/
......@@ -16,9 +14,8 @@ class Url
private $path = '';
private $fragment;
private static $defaultPorts = ['http' => 80, 'https' => 443, 'ftp' => 21];
private static $pathPattern = '/[^a-zA-Z0-9\-\._~!\$&\'\(\)\*\+,;=%:@\/]+|%(?![A-Fa-f0-9]{2})/';
private static $queryPattern = '/[^a-zA-Z0-9\-\._~!\$\'\(\)\*\+,;%:@\/\?=&]+|%(?![A-Fa-f0-9]{2})/';
/** @var Query|string Query part of the URL */
/** @var Query Query part of the URL */
private $query;
/**
......@@ -31,9 +28,9 @@ class Url
*/
public static function fromString($url)
{
static $defaults = ['scheme' => null, 'host' => null,
static $defaults = array('scheme' => null, 'host' => null,
'path' => null, 'port' => null, 'query' => null,
'user' => null, 'pass' => null, 'fragment' => null];
'user' => null, 'pass' => null, 'fragment' => null);
if (false === ($parts = parse_url($url))) {
throw new \InvalidArgumentException('Unable to parse malformed '
......@@ -119,14 +116,14 @@ public static function buildUrl(array $parts)
/**
* Create a new URL from URL parts
*
* @param string $scheme Scheme of the URL
* @param string $host Host of the URL
* @param string $username Username of the URL
* @param string $password Password of the URL
* @param int $port Port of the URL
* @param string $path Path of the URL
* @param string $scheme Scheme of the URL
* @param string $host Host of the URL
* @param string $username Username of the URL
* @param string $password Password of the URL
* @param int $port Port of the URL
* @param string $path Path of the URL
* @param Query|array|string $query Query string of the URL
* @param string $fragment Fragment of the URL
* @param string $fragment Fragment of the URL
*/
public function __construct(
$scheme,
......@@ -144,11 +141,11 @@ public function __construct(
$this->username = $username;
$this->password = $password;
$this->fragment = $fragment;
if ($query) {
if (!$query) {
$this->query = new Query();
} else {
$this->setQuery($query);
}
$this->setPath($path);
}
......@@ -157,9 +154,7 @@ public function __construct(
*/
public function __clone()
{
if ($this->query instanceof Query) {
$this->query = clone $this->query;
}
$this->query = clone $this->query;
}
/**
......@@ -227,9 +222,8 @@ public function getHost()
public function setScheme($scheme)
{
// Remove the default port if one is specified
if ($this->port
&& isset(self::$defaultPorts[$this->scheme])
&& self::$defaultPorts[$this->scheme] == $this->port
if ($this->port && isset(self::$defaultPorts[$this->scheme]) &&
self::$defaultPorts[$this->scheme] == $this->port
) {
$this->port = null;
}
......@@ -277,15 +271,15 @@ public function getPort()
}
/**
* Set the path part of the URL.
*
* The provided URL is URL encoded as necessary.
* Set the path part of the URL
*
* @param string $path Path string to set
*/
public function setPath($path)
{
$this->path = self::encodePath($path);
static $search = [' ', '?'];
static $replace = ['%20', '%3F'];
$this->path = str_replace($search, $replace, $path);
}
/**
......@@ -417,52 +411,29 @@ public function getUsername()
*/
public function getQuery()
{
// Convert the query string to a query object if not already done.
if (!$this->query instanceof Query) {
$this->query = $this->query === null
? new Query()
: Query::fromString($this->query);
}
return $this->query;
}
/**
* Set the query part of the URL.
*
* You may provide a query string as a string and pass $rawString as true
* to provide a query string that is not parsed until a call to getQuery()
* is made. Setting a raw query string will still encode invalid characters
* in a query string.
* Set the query part of the URL
*
* @param Query|string|array $query Query string value to set. Can
* be a string that will be parsed into a Query object, an array
* of key value pairs, or a Query object.
* @param bool $rawString Set to true when providing a raw query string.
*
* @throws \InvalidArgumentException
*/
public function setQuery($query, $rawString = false)
public function setQuery($query)
{
if ($query instanceof Query) {
$this->query = $query;
} elseif (is_string($query)) {
if (!$rawString) {
$this->query = Query::fromString($query);
} else {
// Ensure the query does not have illegal characters.
$this->query = preg_replace_callback(
self::$queryPattern,
[__CLASS__, 'encodeMatch'],
$query
);
}
$this->query = Query::fromString($query);
} elseif (is_array($query)) {
$this->query = new Query($query);
} else {
throw new \InvalidArgumentException('Query must be a Query, '
. 'array, or string. Got ' . Core::describeType($query));
. 'array, or string. ' . gettype($query) . ' provided.');
}
}
......@@ -520,7 +491,16 @@ public function combine($url)
// Passing a URL with a scheme overrides everything
if ($parts['scheme']) {
return clone $url;
return new static(
$parts['scheme'],
$parts['host'],
$parts['user'],
$parts['pass'],
$parts['port'],
$parts['path'],
clone $parts['query'],
$parts['fragment']
);
}
// Setting a host overrides the entire rest of the URL
......@@ -532,9 +512,7 @@ public function combine($url)
$parts['pass'],
$parts['port'],
$parts['path'],
$parts['query'] instanceof Query
? clone $parts['query']
: $parts['query'],
clone $parts['query'],
$parts['fragment']
);
}
......@@ -542,7 +520,7 @@ public function combine($url)
if (!$parts['path'] && $parts['path'] !== '0') {
// The relative URL has no path, so check if it is just a query
$path = $this->path ?: '';
$query = $parts['query'] ?: $this->query;
$query = count($parts['query']) ? $parts['query'] : $this->query;
} else {
$query = $parts['query'];
if ($parts['path'][0] == '/' || !$this->path) {
......@@ -563,7 +541,7 @@ public function combine($url)
$this->password,
$this->port,
$path,
$query instanceof Query ? clone $query : $query,
clone $query,
$parts['fragment']
);
......@@ -573,23 +551,4 @@ public function combine($url)
return $result;
}
/**
* Encodes the path part of a URL without double-encoding percent-encoded
* key value pairs.
*
* @param string $path Path to encode
*
* @return string
*/
public static function encodePath($path)
{
static $cb = [__CLASS__, 'encodeMatch'];
return preg_replace_callback(self::$pathPattern, $cb, $path);
}
private static function encodeMatch(array $match)
{
return rawurlencode($match[0]);
}
}