Skip to content

HttpClient: Separate Client from Transports#19

Merged
adamziel merged 10 commits intotrunkfrom
transports-middlewares
May 29, 2025
Merged

HttpClient: Separate Client from Transports#19
adamziel merged 10 commits intotrunkfrom
transports-middlewares

Conversation

@adamziel
Copy link
Copy Markdown
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 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