Update core 8.3.0

This commit is contained in:
Rob Davies 2017-04-13 15:53:35 +01:00
parent da7a7918f8
commit cd7a898e66
6144 changed files with 132297 additions and 87747 deletions

View file

@ -6,11 +6,11 @@ php:
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm
before_script:
- curl --version
- composer self-update
- composer install --no-interaction --prefer-source --dev
- ~/.nvm/nvm.sh install v0.6.14
- ~/.nvm/nvm.sh run v0.6.14

View file

@ -1,5 +1,16 @@
# CHANGELOG
## 6.2.3 - 2017-02-28
* Fix deprecations with guzzle/psr7 version 1.4
## 6.2.2 - 2016-10-08
* Allow to pass nullable Response to delay callable
* Only add scheme when host is present
* Fix drain case where content-length is the literal string zero
* Obfuscate in-URL credentials in exceptions
## 6.2.1 - 2016-07-18
* Address HTTP_PROXY security vulnerability, CVE-2016-5385:
@ -746,7 +757,7 @@ interfaces.
* Deprecating Response::getRequest() and now using a shallow clone of a request object to remove a circular reference
to help with refcount based garbage collection of resources created by sending a request
* Deprecating ZF1 cache and log adapters. These will be removed in the next major version.
* Deprecating `Response::getPreviousResponse()` (method signature still exists, but it'sdeprecated). Use the
* Deprecating `Response::getPreviousResponse()` (method signature still exists, but it's deprecated). Use the
HistoryPlugin for a history.
* Added a `responseBody` alias for the `response_body` location
* Refactored internals to no longer rely on Response::getRequest()

View file

@ -132,7 +132,7 @@ $handler = GuzzleHttp\HandlerStack::create();
$handler->push(Middleware::mapRequest(function (RequestInterface $request) {
// Notice that we have to return a request object
return $request->withHeader('X-Foo', 'Bar');
});
}));
// Inject the handler into the client
$client = new GuzzleHttp\Client(['handler' => $handler]);
```
@ -600,7 +600,7 @@ these if needed):
The following plugins are not part of the core Guzzle package, but are provided
in separate repositories:
- `Guzzle\Http\Plugin\BackoffPlugin` has been rewritten to be muchs simpler
- `Guzzle\Http\Plugin\BackoffPlugin` has been rewritten to be much simpler
to build custom retry policies using simple functions rather than various
chained classes. See: https://github.com/guzzle/retry-subscriber
- `Guzzle\Http\Plugin\Cache\CachePlugin` has moved to
@ -664,8 +664,8 @@ that contain additional metadata accessible via `getMetadata()`.
The entire concept of the StreamRequestFactory has been removed. The way this
was used in Guzzle 3 broke the actual interface of sending streaming requests
(instead of getting back a Response, you got a StreamInterface). Streeaming
PHP requests are now implemented throught the `GuzzleHttp\Adapter\StreamAdapter`.
(instead of getting back a Response, you got a StreamInterface). Streaming
PHP requests are now implemented through the `GuzzleHttp\Adapter\StreamAdapter`.
3.6 to 3.7
----------

View file

@ -14,7 +14,7 @@
],
"require": {
"php": ">=5.5",
"guzzlehttp/psr7": "^1.3.1",
"guzzlehttp/psr7": "^1.4",
"guzzlehttp/promises": "^1.0"
},
"require-dev": {

View file

@ -9,18 +9,18 @@ use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
/**
* @method ResponseInterface get($uri, array $options = [])
* @method ResponseInterface head($uri, array $options = [])
* @method ResponseInterface put($uri, array $options = [])
* @method ResponseInterface post($uri, array $options = [])
* @method ResponseInterface patch($uri, array $options = [])
* @method ResponseInterface delete($uri, array $options = [])
* @method Promise\PromiseInterface getAsync($uri, array $options = [])
* @method Promise\PromiseInterface headAsync($uri, array $options = [])
* @method Promise\PromiseInterface putAsync($uri, array $options = [])
* @method Promise\PromiseInterface postAsync($uri, array $options = [])
* @method Promise\PromiseInterface patchAsync($uri, array $options = [])
* @method Promise\PromiseInterface deleteAsync($uri, array $options = [])
* @method ResponseInterface get(string|UriInterface $uri, array $options = [])
* @method ResponseInterface head(string|UriInterface $uri, array $options = [])
* @method ResponseInterface put(string|UriInterface $uri, array $options = [])
* @method ResponseInterface post(string|UriInterface $uri, array $options = [])
* @method ResponseInterface patch(string|UriInterface $uri, array $options = [])
* @method ResponseInterface delete(string|UriInterface $uri, array $options = [])
* @method Promise\PromiseInterface getAsync(string|UriInterface $uri, array $options = [])
* @method Promise\PromiseInterface headAsync(string|UriInterface $uri, array $options = [])
* @method Promise\PromiseInterface putAsync(string|UriInterface $uri, array $options = [])
* @method Promise\PromiseInterface postAsync(string|UriInterface $uri, array $options = [])
* @method Promise\PromiseInterface patchAsync(string|UriInterface $uri, array $options = [])
* @method Promise\PromiseInterface deleteAsync(string|UriInterface $uri, array $options = [])
*/
class Client implements ClientInterface
{
@ -142,10 +142,10 @@ class Client implements ClientInterface
$uri = Psr7\uri_for($uri === null ? '' : $uri);
if (isset($config['base_uri'])) {
$uri = Psr7\Uri::resolve(Psr7\uri_for($config['base_uri']), $uri);
$uri = Psr7\UriResolver::resolve(Psr7\uri_for($config['base_uri']), $uri);
}
return $uri->getScheme() === '' ? $uri->withScheme('http') : $uri;
return $uri->getScheme() === '' && $uri->getHost() !== '' ? $uri->withScheme('http') : $uri;
}
/**

View file

@ -4,6 +4,7 @@ namespace GuzzleHttp\Exception;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use GuzzleHttp\Promise\PromiseInterface;
use Psr\Http\Message\UriInterface;
/**
* HTTP Request exception
@ -89,12 +90,15 @@ class RequestException extends TransferException
$className = __CLASS__;
}
$uri = $request->getUri();
$uri = static::obfuscateUri($uri);
// 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(),
$request->getMethod() . ' ' . $uri,
$response->getStatusCode() . ' ' . $response->getReasonPhrase()
);
@ -141,6 +145,24 @@ class RequestException extends TransferException
return $summary;
}
/**
* Obfuscates URI if there is an username and a password present
*
* @param UriInterface $uri
*
* @return UriInterface
*/
private static function obfuscateUri($uri)
{
$userInfo = $uri->getUserInfo();
if (false !== ($pos = strpos($userInfo, ':'))) {
return $uri->withUserInfo(substr($userInfo, 0, $pos), '***');
}
return $uri;
}
/**
* Get the request that caused the exception
*

View file

@ -210,7 +210,7 @@ class StreamHandler
Psr7\copy_to_stream(
$source,
$sink,
strlen($contentLength) > 0 ? (int) $contentLength : -1
(strlen($contentLength) > 0 && (int) $contentLength > 0) ? (int) $contentLength : -1
);
$sink->seek(0);

View file

@ -208,9 +208,9 @@ class RedirectMiddleware
ResponseInterface $response,
array $protocols
) {
$location = Psr7\Uri::resolve(
$location = Psr7\UriResolver::resolve(
$request->getUri(),
$response->getHeaderLine('Location')
new Psr7\Uri($response->getHeaderLine('Location'))
);
// Ensure that the redirect URI is allowed based on the protocols.

View file

@ -43,8 +43,8 @@ final class RequestOptions
const AUTH = 'auth';
/**
* body: (string|null|callable|iterator|object) Body to send in the
* request.
* body: (resource|string|null|int|float|StreamInterface|callable|\Iterator)
* Body to send in the request.
*/
const BODY = 'body';

View file

@ -5,6 +5,7 @@ use GuzzleHttp\Promise\PromiseInterface;
use GuzzleHttp\Promise\RejectedPromise;
use GuzzleHttp\Psr7;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
/**
* Middleware that retries requests based on the boolean result of
@ -25,8 +26,8 @@ class RetryMiddleware
* retried.
* @param callable $nextHandler Next handler to invoke.
* @param callable $delay Function that accepts the number of retries
* and returns the number of milliseconds to
* delay.
* and [response] and returns the number of
* milliseconds to delay.
*/
public function __construct(
callable $decider,
@ -82,7 +83,7 @@ class RetryMiddleware
)) {
return $value;
}
return $this->doRetry($req, $options);
return $this->doRetry($req, $options, $value);
};
}
@ -102,9 +103,9 @@ class RetryMiddleware
};
}
private function doRetry(RequestInterface $request, array $options)
private function doRetry(RequestInterface $request, array $options, ResponseInterface $response = null)
{
$options['delay'] = call_user_func($this->delay, ++$options['retries']);
$options['delay'] = call_user_func($this->delay, ++$options['retries'], $response);
return $this($request, $options);
}