Skip to content

[WIP] Let guzzle choose the handler for http requests#60167

Draft
julien-nc wants to merge 1 commit intomasterfrom
enh/noid/allow-http-progressive-stream-response
Draft

[WIP] Let guzzle choose the handler for http requests#60167
julien-nc wants to merge 1 commit intomasterfrom
enh/noid/allow-http-progressive-stream-response

Conversation

@julien-nc
Copy link
Copy Markdown
Member

So it can write a streamed response body progressively.

Summary

When using the 'stream' => true request option with IClient, the response body is a resource but its content is written all at once when the request is done.
This happens because the use of the CurlHandler is hardcoded in https://github.com/nextcloud/server/blob/fb67d5d/lib/private/Http/Client/ClientService.php#L44
The Curlhandler makes a blocking call to curl_exec which executes the request synchronously.

To allow progressive streamed responses, we need:

  • to use HTTP 1/*
  • to allow guzzle to use the StreamHandler

This is just a PoC. I have no idea if it's the right thing to do.
Wdyt?

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@julien-nc julien-nc added this to the Nextcloud 34 milestone May 5, 2026
…can write a streamed response body progressively

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
@julien-nc julien-nc force-pushed the enh/noid/allow-http-progressive-stream-response branch from 6eeca81 to 9c49a16 Compare May 7, 2026 12:23
#[\Override]
public function newClient(): IClient {
$handler = new CurlHandler();
$handler = Utils::chooseHandler();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It lets Guzzle choose the handler depending on the request options. So the StreamHandler is chosen when 'stream' => true is passed to the request options.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! maybe a comment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants