|
|
@@ -406,7 +406,8 @@ class Client
|
|
|
$locationUrl = $this->buildUrl($location, [], [
|
|
|
'host' => $url->getHost(),
|
|
|
'port' => $url->getPort(),
|
|
|
- 'scheme' => $url->getScheme()
|
|
|
+ 'scheme' => $url->getScheme(),
|
|
|
+ 'protocolRelative' => true
|
|
|
]);
|
|
|
|
|
|
$request = $request->withUri(new Uri($locationUrl));
|
|
|
@@ -452,15 +453,21 @@ class Client
|
|
|
$url .= $q;
|
|
|
$url .= is_string($query) ? $query : http_build_query($query);
|
|
|
}
|
|
|
- if (preg_match('#^https?://#', $url)) {
|
|
|
- return $url;
|
|
|
- }
|
|
|
$defaults = [
|
|
|
'host' => null,
|
|
|
'port' => null,
|
|
|
'scheme' => 'http',
|
|
|
+ 'protocolRelative' => false
|
|
|
];
|
|
|
$options += $defaults;
|
|
|
+
|
|
|
+ if ($options['protocolRelative'] && preg_match('#^//#', $url)) {
|
|
|
+ $url = $options['scheme'] . ':' . $url;
|
|
|
+ }
|
|
|
+ if (preg_match('#^https?://#', $url)) {
|
|
|
+ return $url;
|
|
|
+ }
|
|
|
+
|
|
|
$defaultPorts = [
|
|
|
'http' => 80,
|
|
|
'https' => 443
|