updated core and modules

This commit is contained in:
Bachir Soussi Chiadmi
2017-09-09 16:27:51 +02:00
parent 027aa99b32
commit 41863f872c
7810 changed files with 318922 additions and 83631 deletions
+14 -14
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;
}
/**
+23 -1
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
*
+1 -1
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);
+2 -2
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.
+2 -2
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';
+6 -5
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);
}