summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2024-02-26 17:05:52 +0100
committerJoas Schilling <coding@schilljs.com>2024-02-27 09:06:56 +0100
commit028e3c8e1e805971ca02615dd6ce96d0e67b4f16 (patch)
tree220d8602603e120b4deb0e900757e5628e16ad51 /lib
parent37d52050f5f3a3534db408dc925972954ed64351 (diff)
fix(federation): Add missing protocol
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Federation/Proxy/TalkV1/ProxyRequest.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Federation/Proxy/TalkV1/ProxyRequest.php b/lib/Federation/Proxy/TalkV1/ProxyRequest.php
index fee39bd02..224a952d8 100644
--- a/lib/Federation/Proxy/TalkV1/ProxyRequest.php
+++ b/lib/Federation/Proxy/TalkV1/ProxyRequest.php
@@ -78,6 +78,13 @@ class ProxyRequest {
];
}
+ protected function prependProtocolIfNotAvailable(string $url): string {
+ if (!str_starts_with($url, 'http://') && !str_starts_with($url, 'https://')) {
+ $url = 'https://' . $url;
+ }
+ return $url;
+ }
+
/**
* @param 'get'|'post'|'put'|'delete' $verb
* @throws CannotReachRemoteException
@@ -96,7 +103,10 @@ class ProxyRequest {
}
try {
- return $this->clientService->newClient()->{$verb}($url, $requestOptions);
+ return $this->clientService->newClient()->{$verb}(
+ $this->prependProtocolIfNotAvailable($url),
+ $requestOptions
+ );
} catch (ClientException $e) {
$status = $e->getResponse()->getStatusCode();