From ec596d35d40359902a9b4e8dcf8ad9f41acda3b0 Mon Sep 17 00:00:00 2001 From: aminovfariz Date: Thu, 28 May 2026 13:14:19 +0200 Subject: [PATCH] fix(auth): extend stream-based HTTP to POST requests in OidcHttpGateway Co-Authored-By: Claude Sonnet 4.6 --- core/Service/Auth/OidcHttpGateway.php | 29 ++++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/core/Service/Auth/OidcHttpGateway.php b/core/Service/Auth/OidcHttpGateway.php index 16039d3..bb71f5d 100644 --- a/core/Service/Auth/OidcHttpGateway.php +++ b/core/Service/Auth/OidcHttpGateway.php @@ -11,32 +11,41 @@ class OidcHttpGateway */ public function call(string $method, string $url, mixed $data = '', array $headers = []): array { - if (strtoupper($method) === 'GET') { - return $this->getWithStream($url, $headers); - } - return Curl::call($method, $url, $data, $headers); + return $this->callWithStream(strtoupper($method), $url, $data, $headers); } /** * @param array $headers */ - private function getWithStream(string $url, array $headers): array + private function callWithStream(string $method, string $url, mixed $data, array $headers): array { $headerLines = []; foreach ($headers as $key => $value) { $headerLines[] = $key . ': ' . $value; } + + $httpContext = [ + 'method' => $method, + 'header' => implode("\r\n", $headerLines), + 'ignore_errors' => true, + ]; + + if ($method === 'POST') { + $body = is_array($data) ? http_build_query($data) : (string) $data; + $httpContext['content'] = $body; + if (!isset($headers['Content-Type'])) { + $httpContext['header'] .= "\r\nContent-Type: application/x-www-form-urlencoded"; + } + } + $ctx = stream_context_create([ - 'http' => [ - 'method' => 'GET', - 'header' => implode("\r\n", $headerLines), - 'ignore_errors' => true, - ], + 'http' => $httpContext, 'ssl' => [ 'verify_peer' => true, 'verify_peer_name' => true, ], ]); + $body = @file_get_contents($url, false, $ctx); $status = 0; $responseHeaders = [];