composer-update-patch

This commit is contained in:
Manish Verma
2016-11-03 05:44:29 +05:30
parent 2dca47f5a4
commit 5d49d384a0
5118 changed files with 51603 additions and 122575 deletions

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
{
@@ -145,7 +145,7 @@ class Client implements ClientInterface
$uri = Psr7\Uri::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

@@ -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);
}