wp-php-toolkit/http-client
最新稳定版本:v0.4.1
Composer 安装命令:
composer require wp-php-toolkit/http-client
包简介
HttpClient component for WordPress.
README 文档
README
An asynchronous HTTP client library.
Key Features
- No dependencies: Works on vanilla PHP without external libraries.
SocketClientusesstream_socket_client()for non-blocking HTTP requests andCurlClientusescurl_multifor parallel requests. - Streaming support: Enables efficient handling of large response bodies.
- Progress monitoring: Track the progress of requests and responses.
- Concurrency limits: Control the number of simultaneous connections.
- PHP 7.2+ support and no dependencies: Works on vanilla PHP without external libraries.
Usage Example
$requests = [ new Request("[https://wordpress.org/latest.zip](https://wordpress.org/latest.zip)"), new Request("[https://raw.githubusercontent.com/wpaccessibility/a11y-theme-unit-test/master/a11y-theme-unit-test-data.xml](https://raw.githubusercontent.com/wpaccessibility/a11y-theme-unit-test/master/a11y-theme-unit-test-data.xml)"), ]; // Creates the most appropriate client based for your environment. $client = Client::create(); $client->enqueue($requests); while ($client->await_next_event()) { $event = $client->get_event(); $request = $client->get_request(); if ($event === Client::EVENT_BODY_CHUNK_AVAILABLE) { $chunk = $client->get_response_body_chunk(); // Process the chunk... } // Handle other events... }
TODO
- Request headers – accept string lines such as "Content-type: text/plain" instead of key-value pairs. K/V pairs
are confusing and lead to accidental errors such as
0: Content-type: text/plain. They also diverge from the format that curl accepts. - Response caching – add a custom cache handler for easy caching of the same URLs
- Response caching – support HTTP cache-control headers
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2025-09-06