FOSSology  4.5.1
Open Source License Compliance by Open Source Software
Fossology\Lib\Util\HttpUtils Class Reference
Collaboration diagram for Fossology\Lib\Util\HttpUtils:
Collaboration graph

Static Public Member Functions

static getGuzzleClient (array $SysConf, string $baseUri, string $token="")
 
static checkLicenseDBHealth (string $getHealth, $guzzleClient)
 
static processHttpResponse ($response)
 

Detailed Description

Definition at line 16 of file HttpUtils.php.

Member Function Documentation

◆ checkLicenseDBHealth()

static Fossology\Lib\Util\HttpUtils::checkLicenseDBHealth ( string  $getHealth,
  $guzzleClient 
)
static

Checks the health status of the license database by sending a GET request to a specified health endpoint. Returns a boolean result indicating whether the database is reachable and healthy. Implements error handling for HTTP request failures.

Returns
bool True if the database health check succeeds with an HTTP 200 response, false otherwise.

Definition at line 62 of file HttpUtils.php.

◆ getGuzzleClient()

static Fossology\Lib\Util\HttpUtils::getGuzzleClient ( array  $SysConf,
string  $baseUri,
string  $token = "" 
)
static

Create a preconfigured Guzzle Client.

Parameters
array$SysConfSysConf array
string$baseUriBase URI of the client
string$tokenAuthentication token. Leave empty if not needed.
Returns
Client Guzzle Client configured with proxy

Definition at line 25 of file HttpUtils.php.

◆ processHttpResponse()

static Fossology\Lib\Util\HttpUtils::processHttpResponse (   $response)
static

Processes an HTTP response and handles it based on the status code.

This function evaluates the HTTP response status code and performs the following:

  • For a 200 status code, it decodes the JSON response body and validates the data.
  • For other status codes, it throws exceptions with appropriate error messages.
Parameters
\Psr\Http\Message\ResponseInterface$responseThe HTTP response object to process.
Returns
mixed Decoded JSON data from the response body if the status code is 200.
Exceptions
HttpClientExceptionIf the response contains errors, invalid JSON, or unexpected status codes.

Definition at line 89 of file HttpUtils.php.


The documentation for this class was generated from the following file: