Skip to content

Add streaming support to WordPress_HTTP_Client #11

@felixarntz

Description

@felixarntz

Follow-up to #2, and pending WordPress/php-ai-client#100: We need to ensure the WordPress_HTTP_Client supports streaming responses.

Unfortunately, WordPress (and its Requests library) do not support this. So we'll need to likely come with our own implementation (e.g. use Guzzle) that still ties in with the WordPress way to make requests as much as possible.

This will mean duplicating quite a bit of WordPress Core code that isn't properly abstracted out. But that may be the lesser evil of the alternative of trying to properly build support for response streaming into WordPress Core, which would be subject to several bottlenecks (e.g. the Requests library has barely any active maintenance).

For additional context, see this comment: #2 (comment)

Also, adding some references for how I solved this in the AI Services plugin for WordPress, using Guzzle under the hood while keeping things WordPress-y otherwise (most importantly run the necessary hooks):

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions