-
Notifications
You must be signed in to change notification settings - Fork 2
LibHttp
LibHttp is the official HTTP helper library for EasyLibrary 3.x.
| Field | Value |
|---|---|
| Package id | libhttp |
| Plugin name | LibHttp |
| Namespace | imperazim\http |
| Type | classpath package |
| Repository | https://github.com/ImperaZim/LibHttp |
| Required package | libcommons |
- immutable HTTP request and response objects;
- cURL transport with PHP stream fallback;
- retry policies for transient network/status failures;
- auth header helpers for bearer token, basic auth and API-key headers;
- lightweight request/response interceptors for default headers, request mutation and response observation;
- local fixed-window rate limiting with an injectable clock for tests;
- typed exceptions for transport, status, JSON and download failures;
- JSON request and response helpers;
- atomic downloads with optional max-size and SHA-256 checks;
- generic webhook helpers and Discord webhook payload builders;
- PMMP async task adapter for request callbacks.
LibHttp uses LibCommons for generic JSON, URL validation, SHA-256 and
atomic filesystem helpers. HTTP request/response, retry, transport, webhook and
download contracts remain owned by LibHttp.
Bearer token request:
use imperazim\http\auth\HttpAuth;
use imperazim\http\HttpRequest;
$request = HttpRequest::get('https://example.com/api/private')
->withHeaders(HttpAuth::bearerToken($token));Default headers and local throttling:
use imperazim\http\client\HttpClient;
use imperazim\http\interceptor\DefaultHeadersInterceptor;
use imperazim\http\rate\FixedWindowRateLimiter;
$client = new HttpClient(
interceptors: [new DefaultHeadersInterceptor(['User-Agent' => 'MyPlugin/1.0'])],
rateLimiter: FixedWindowRateLimiter::perSecond(5)
);Typed failures:
use imperazim\http\exception\StatusHttpException;
use imperazim\http\exception\TransportHttpException;
try {
$client->sendOrFail($request);
} catch (TransportHttpException) {
// Connection, DNS, timeout or TLS failure.
} catch (StatusHttpException $error) {
$status = $error->getResponse()->getStatusCode();
}/easylibrary packages install libhttp development confirm
Restart, then validate:
/easylibrary packages status libhttp
/elprobe libhttp
/elprobe run libhttp
Download LibHttp-1.0.0-dev.phar from the GitHub Release and place it under
plugins/, then restart the server.
LibHttp replaces the old idea of keeping HTTP/download/webhook helpers inside
the EasyLibrary core. The core can still perform its own private package
downloads, but public plugin-facing HTTP helpers belong here.
Use the repository examples when you want copyable code instead of API lists:
- https://github.com/ImperaZim/LibHttp/tree/development/examples
-
examples/api_webhook_download.phpcombines external JSON API reads, Discord webhooks and checksum-verified downloads.
The examples are linted by the LibHttp quality workflow so docs and public API usage stay aligned.
- Package Manager
- Package Backed Plugins
- Standalone vs Package
- Package Switch and Migration
- Package Doctor
- Package Safety Gate
- Support Report Bundle
- Timings
- Runtime Notifications
- Package Recovery
- Proxy Troubleshooting
- Migrating from EasyLibrary 2.0 to 3.x
- Embedded Libraries Migration Map
- Removed Features and Replacements
- Deprecated APIs
- Compatibility Policy
- Config Migration
- 3x Dev Scope Checkpoint
- Plugin Developer Migration
- Server Administrator Migration
- Official Libraries
- LibPacket
- LibCommand
- LibSerializer
- LibForm
- LibDB
- LibCommons
- LibHttp
- LibAssets
- LibRuntimeInspector
- LibRuntimeGuard
- LibPlaceholder
- LibWorld
- LibModule
- EasyLibrary Agent Bridge
- LibCustom
- LibEnchantment
- LibHud
- LibTrigger
- LibWindow
- Public API Contract
- Module Boundary
- Module Smoke Matrix
- LibAsync Incubator
- LibReflect Incubator
- Doctor Output
- Repository Notifications
- Smoke Tests
- Common Errors
- Release and Changelog