From e048bd9eea82e48fc2cdf56851034c88ef3b144c Mon Sep 17 00:00:00 2001 From: Victor Westerlund Date: Thu, 27 Apr 2023 17:19:24 +0200 Subject: [PATCH] wip: 1682608764 --- src/Reflect/Client.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Reflect/Client.php b/src/Reflect/Client.php index b715489..3367493 100644 --- a/src/Reflect/Client.php +++ b/src/Reflect/Client.php @@ -27,10 +27,13 @@ $this->_endpoint = $endpoint; $this->_key = $key; - // Initialize socket if ($this->_con === Connection::AF_UNIX) { + // Connect to Reflect UNIX socket $this->_socket = socket_create(AF_UNIX, SOCK_STREAM, 0); $conn = socket_connect($this->_socket, $this->_endpoint); + } else if ($this->_con === Connection::HTTP) { + // Append tailing "/" for HTTP if absent + $this->_endpoint = substr($this->_endpoint, -1) === "/" ? $this->_endpoint : $this->_endpoint . "/"; } } @@ -67,6 +70,8 @@ private function http_call(string $endpoint, Method|string $method = (__CLASS__)::HTTP_DEFAULT_METHOD, array $payload = null): array { // Resolve string to enum $method = $this::resolve_method($method); + // Remove leading "/" if present, as it's already present in $this->_endpoint + $endpoint = substr($endpoint, 0, 1) !== "/" ? $endpoint : substr($endpoint, 1, strlen($endpoint) - 1); $data = stream_context_create([ "http" => [