Skip to content
This repository was archived by the owner on May 30, 2025. It is now read-only.

HttpClient: Separate Client from Transports #19

Merged
merged 10 commits into from
May 29, 2025
Merged

Conversation

adamziel
Copy link
Contributor

@adamziel adamziel commented May 26, 2025

Replaces inheritance (AbstractClient > CurlClient, SocketsClient) with a single Client class that uses either a SocketsTransport or CurlTransport:

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

// Transport is auto-selected:
$client = new Client();

// You can also choose a transport explicitly:
$client = new Client([ 'transport' => 'curl' ]);
$client = new Client([ 'transport' => 'sockets' ]);

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

This is a pre-requisite to #18

Testing instructions

Tests are included – confirm the CI checks pass

@adamziel adamziel marked this pull request as draft May 26, 2025 11:18
@adamziel adamziel marked this pull request as ready for review May 29, 2025 20:46
@adamziel adamziel merged commit d9ef6ec into trunk May 29, 2025
20 of 21 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant