![]() |
Bearsampp 2026.9.23
|
Static Public Member Functions | |
| static | applyCurlSslOptions ($ch, $verify=true) |
| static | checkInternetState () |
| static | downloadFile (string $url, string $filePath, $progressBar=false, $verify=true) |
| static | fetchGet ($url, $verify=true) |
| static | getApiJson ($url, $verify=true) |
| static | getCacertPath () |
| static | getChangelogUrl ($utmSource=true) |
| static | getCurlHttpHeaders ($url, $verify=true) |
| static | getFopenHttpHeaders ($url, $verify=true) |
| static | getGithubUrl ($type='user', $user=APP_GITHUB_USER, $repo=null, $branch=null, $path=null) |
| static | getGithubUserUrl () |
| static | getHeaders ($host, $port, $ssl=false) |
| static | getHttpHeaders ($pingUrl, $verify=true) |
| static | getSslStreamContext ($verify=true, $url=null) |
| static | getWebsiteUrl ($path='', $fragment='', $utmSource=true) |
| static | getWebsiteUrlNoUtm ($path='', $fragment='') |
| static | isGithubHost ($url) |
| static | proxyDownload ($url, $filePath, $progressBar=false, $verify=true) |
| static | proxyFetch ($url, $method='GET', $verify=true) |
| static | redactUrl ($url) |
Data Fields | |
| const | PROXY_CONNECT_TIMEOUT = 30 |
| const | PROXY_LOW_SPEED_LIMIT = 1024 |
| const | PROXY_LOW_SPEED_TIME = 30 |
Static Private Member Functions | |
| static | safeUrlForLog ($url) |
Definition at line 19 of file class.httpclient.php.
|
static |
Applies certificate verification options to a cURL handle.
When $verify is true the peer certificate is checked against the bundled CA bundle. Pass false only for local/self-signed endpoints (e.g. the app's own Apache SSL).
| resource | $ch | The cURL handle. |
| bool | $verify | Whether to verify the peer certificate. Defaults to true. |
Definition at line 497 of file class.httpclient.php.
References getCacertPath().
Referenced by fetchGet(), getCurlHttpHeaders(), proxyDownload(), and proxyFetch().
|
static |
Checks the current state of the internet connection.
Opens a verified TLS connection to the project's own website over port 443. This keeps the probe encrypted (no plaintext traffic to a third party) and independent of external hosts such as Google.
Definition at line 830 of file class.httpclient.php.
References APP_WEBSITE.
Referenced by QuickPick\installModule().
|
static |
Downloads a file from a given URL and saves it to a specified file path.
GitHub-hosted archives are downloaded through the GitHub proxy. Non-GitHub URLs are streamed over a verified TLS connection in 8KB chunks to avoid loading the whole file into memory, emitting one JSON progress line per chunk when $progressBar is enabled.
| string | $url | The URL from which to fetch the file content. |
| string | $filePath | The path where the file content should be saved. |
| bool | $progressBar | Optional. Whether to display a progress bar during the download process. Default is false. |
| bool | $verify | Whether to verify the peer certificate. Defaults to true. Pass false only for local/self-signed endpoints. |
Definition at line 756 of file class.httpclient.php.
References Log\error(), proxyDownload(), and Log\trace().
Referenced by QuickPick\fetchAndUnzipModule().
|
static |
Sends a GET request to the specified URL and returns the trimmed response body.
This is the generic non-proxied GET method. For GitHub-hosted URLs, prefer {
The peer certificate is verified against the bundled CA bundle unless $verify is false (used only for local/self-signed endpoints).
| string | $url | The URL to send the GET request to. |
| bool | $verify | Whether to verify the peer certificate. Defaults to true. |
Definition at line 305 of file class.httpclient.php.
References APP_GITHUB_REPO, APP_GITHUB_USER, APP_GITHUB_USERAGENT, applyCurlSslOptions(), and Log\error().
Referenced by getApiJson().
|
static |
Sends a GET request to the specified URL and returns the response.
GitHub-hosted URLs are fetched through the GitHub proxy so no token is ever sent by the client. Non-GitHub URLs are fetched directly over verified TLS.
| string | $url | The URL to send the GET request to. |
| bool | $verify | Whether to verify the peer certificate. Defaults to true. |
Definition at line 336 of file class.httpclient.php.
References $result, Log\error(), fetchGet(), proxyFetch(), and Log\trace().
Referenced by Util\getLatestVersion(), and QuickPick\rebuildQuickpickJson().
|
static |
Returns the path to the CA bundle shipped with the PHP installation.
Definition at line 391 of file class.httpclient.php.
References Path\getPhpPath().
Referenced by applyCurlSslOptions(), and getSslStreamContext().
|
static |
Constructs the URL to the changelog page, optionally including UTM parameters.
| bool | $utmSource | Whether to include UTM source parameters. |
Definition at line 169 of file class.httpclient.php.
References getWebsiteUrl().
|
static |
Retrieves HTTP headers from a given URL using cURL.
The peer certificate is verified against the bundled CA bundle unless $verify is false (used only for local/self-signed endpoints).
| string | $url | The URL from which to fetch the headers. |
| bool | $verify | Whether to verify the peer certificate. Defaults to true. |
Definition at line 95 of file class.httpclient.php.
References $response, $result, applyCurlSslOptions(), and Log\trace().
Referenced by getHttpHeaders().
|
static |
Retrieves HTTP headers from a given URL using the fopen function.
The stream context verifies the peer certificate against the bundled CA bundle unless $verify is false (used only for local/self-signed endpoints).
| string | $url | The URL from which to fetch the headers. |
| bool | $verify | Whether to verify the peer certificate. Defaults to true. |
Definition at line 70 of file class.httpclient.php.
References $result.
Referenced by getHttpHeaders().
|
static |
Generates various GitHub URLs based on the specified type.
| string | $type | The type of URL ('user', 'repo', 'raw'). Defaults to 'user'. |
| string | $user | The GitHub username. Defaults to 'Bearsampp'. |
| string | null | $repo | The repository name (required for 'repo' and 'raw' types). |
| string | null | $branch | The branch name (required for 'raw' type). |
| string | null | $path | The file path (required for 'raw' type). |
Definition at line 185 of file class.httpclient.php.
References APP_GITHUB_USER.
Referenced by getGithubUserUrl().
|
static |
Gets the GitHub user URL for Bearsampp.
Definition at line 237 of file class.httpclient.php.
References APP_GITHUB_USER, and getGithubUrl().
Referenced by ActionAbout\__construct(), and ActionAbout\processWindow().
|
static |
Retrieves the initial response line from a specified host and port using a socket connection.
This is a local connectivity probe (used to detect which local service owns a port). Certificate verification is intentionally disabled here: it only reads the first response line from localhost/self-signed services and never processes untrusted content.
| string | $host | The host name or IP address to connect to. |
| int | $port | The port number to connect to. |
| bool | $ssl | Whether to use SSL (defaults to false). |
Definition at line 256 of file class.httpclient.php.
References $port, $result, and Log\trace().
Referenced by BinMailpit\checkPort(), and BinXlight\checkPort().
|
static |
Retrieves HTTP headers from a given URL using either cURL or fopen, depending on availability.
| string | $pingUrl | The URL to ping for headers. |
| bool | $verify | Whether to verify the peer certificate. Defaults to true. Pass false only for local/self-signed endpoints (e.g. the app's own Apache SSL on localhost). |
Definition at line 35 of file class.httpclient.php.
References $result, getCurlHttpHeaders(), getFopenHttpHeaders(), and Log\trace().
Referenced by BinApache\checkPort().
|
static |
Builds a stream context that verifies the peer certificate against the bundled CA bundle.
GitHub-hosted content is fetched through the GitHub proxy (APP_GITHUB_PROXY_URL) instead of directly, so no token is ever attached to fopen-based requests here. The $url parameter is kept for API compatibility.
| bool | $verify | Whether to verify the peer certificate. Defaults to true. |
| string | null | $url | Optional target URL (unused; kept for compatibility). |
Definition at line 468 of file class.httpclient.php.
References getCacertPath().
Referenced by QuickPick\checkDownloadId(), QuickPick\checkQuickpickJson(), and QuickPick\fetchChecksumFromSidecar().
|
static |
Constructs a complete website URL with optional path, fragment, and UTM source parameters.
| string | $path | Optional path to append to the base URL. |
| string | $fragment | Optional fragment to append to the URL. |
| bool | $utmSource | Whether to include UTM source parameters. Defaults to true. |
Definition at line 131 of file class.httpclient.php.
References $bearsamppCore, and APP_WEBSITE.
Referenced by getChangelogUrl(), TplAppApache\getMenuApache(), TplAppMailpit\getMenuMailpit(), TplAppMariadb\getMenuMariadb(), TplAppMemcached\getMenuMemcached(), TplAppMysql\getMenuMysql(), TplAppNodejs\getMenuNodejs(), TplAppPhp\getMenuPhp(), TplAppPostgresql\getMenuPostgresql(), TplAppXlight\getMenuXlight(), QuickPick\getQuickpickMenu(), TplApp\getSectionMenuRight(), getWebsiteUrlNoUtm(), and ActionAbout\processWindow().
|
static |
Constructs a website URL without UTM parameters.
| string | $path | Optional path to append to the base URL. |
| string | $fragment | Optional fragment to append to the URL. |
Definition at line 157 of file class.httpclient.php.
References getWebsiteUrl().
Referenced by ActionAbout\__construct().
|
static |
Determines whether a URL is hosted on GitHub.
Used to decide which requests must be routed through the GitHub proxy. Only these hosts are ever sent to the proxy; everything else (e.g. the QuickPick license API or mirror servers) is fetched directly.
| string | $url | The URL to check. |
Definition at line 372 of file class.httpclient.php.
Referenced by QuickPick\checkQuickpickJson(), and QuickPick\fetchChecksumFromSidecar().
|
static |
Downloads a resource through the GitHub proxy, streaming the body to a file.
Used for large payloads (module archives) fetched from GitHub hosts. The response body is streamed in chunks to the given file so it is never held in memory, and an optional progress bar emits one JSON progress line per 8KB chunk, matching the behaviour of the legacy stream download.
| string | $url | The target GitHub URL to download. |
| string | $filePath | Local path to write the body to. |
| bool | $progressBar | Whether to emit progress lines. Defaults to false. |
| bool | $verify | Whether to verify the peer certificate. Defaults to true. Pass false only for local/self-signed endpoints. |
Definition at line 641 of file class.httpclient.php.
References APP_GITHUB_PROXY_KEY, APP_GITHUB_PROXY_URL, APP_GITHUB_REPO, APP_GITHUB_USER, APP_GITHUB_USERAGENT, applyCurlSslOptions(), Log\error(), and Log\trace().
Referenced by downloadFile().
|
static |
Fetches a resource through the GitHub proxy.
Sends a POST to APP_GITHUB_PROXY_URL carrying the target URL and method as a JSON body, authenticated with the shared public proxy key. The GitHub PAT never leaves the proxy server, so the client holds no token at all.
The proxy key is never logged.
| string | $url | The target GitHub URL to retrieve. |
| string | $method | The upstream method: GET, HEAD or POST. Defaults to GET. |
| bool | $verify | Whether to verify the peer certificate. Defaults to true. |
Definition at line 528 of file class.httpclient.php.
References $response, APP_GITHUB_PROXY_KEY, APP_GITHUB_PROXY_URL, APP_GITHUB_REPO, APP_GITHUB_USER, APP_GITHUB_USERAGENT, applyCurlSslOptions(), Log\error(), and Log\trace().
Referenced by QuickPick\checkQuickpickJson(), QuickPick\fetchChecksumFromSidecar(), and getApiJson().
|
static |
Redacts sensitive query-string parameters from a URL before it is logged.
URLs passed to this class can carry credentials such as an API key or a license/download ID (e.g. ?api_key=...&download_id=...). Writing those verbatim into log files would leak them, so any matching parameter's value is masked.
| string | $url | The URL to redact. |
Definition at line 408 of file class.httpclient.php.
|
staticprivate |
Returns a log-safe representation of a URL, keeping only scheme + host + path.
Query strings, fragments, and any embedded credentials are stripped so sensitive tokens never appear in log files.
| string | $url | The URL to sanitise. |
Definition at line 442 of file class.httpclient.php.
| const PROXY_CONNECT_TIMEOUT = 30 |
Definition at line 21 of file class.httpclient.php.
| const PROXY_LOW_SPEED_LIMIT = 1024 |
Definition at line 22 of file class.httpclient.php.
| const PROXY_LOW_SPEED_TIME = 30 |
Definition at line 23 of file class.httpclient.php.