1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-07-31 13:50:23 +02:00

refactor: return proper response object (#4169)

This commit is contained in:
Dag
2024-07-31 17:30:06 +02:00
committed by GitHub
parent aa3989873c
commit 891c8979a3
28 changed files with 69 additions and 84 deletions

View File

@@ -5,8 +5,8 @@
*
* @param array $httpHeaders E.g. ['Content-type: text/plain']
* @param array $curlOptions Associative array e.g. [CURLOPT_MAXREDIRS => 3]
* @param bool $returnFull Whether to return an array: ['code' => int, 'headers' => array, 'content' => string]
* @return string|array
* @param bool $returnFull Whether to return Response object
* @return string|Response
*/
function getContents(
string $url,
@@ -113,13 +113,7 @@ function getContents(
throw $e;
}
if ($returnFull === true) {
// todo: return the actual response object
return [
'code' => $response->getCode(),
'headers' => $response->getHeaders(),
// For legacy reasons, use 'content' instead of 'body'
'content' => $response->getBody(),
];
return $response;
}
return $response->getBody();
}