Skip to content

HttpClient: Separate Client from Transports #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: trunk
Choose a base branch
from

Conversation

adamziel
Copy link
Contributor

@adamziel adamziel commented May 26, 2025

Pre-requisite to #18 (on hold)

Drops client subclasses (AbstractClient > CurlClient, SocketsClient) in favor of transports. With this PR, there's only a single Client class that uses either CurlTransport or SocketsTransport internally.

Usage:

<?php
use WordPress\HttpClient\Request;
use WordPress\HttpClient\Client;

$client = new Client([
	// transport is auto-selected to the fastest one available, but you can
	// also choose one with:
	// 'transport' => 'curl',
	// or
	// 'transport' => 'sockets',
]);

$client->enqueue( new Request('https://w.org/') );
while($client->await_next_event([$request])) {

}

@adamziel adamziel marked this pull request as draft May 26, 2025 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant