Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[13.x] Add support for streamed HTTP client responses#59639

Draft
ahinkle wants to merge 1 commit into
laravel:13.xfrom
ahinkle:http-client-stream
Draft

[13.x] Add support for streamed HTTP client responses#59639
ahinkle wants to merge 1 commit into
laravel:13.xfrom
ahinkle:http-client-stream

Conversation

@ahinkle
Copy link
Copy Markdown
Contributor

@ahinkle ahinkle commented Apr 10, 2026

This PR adds first-class support for consuming streamed HTTP responses (NDJSON, SSE from LLMs, log tailing, or any line-delimited protocol) without dropping out of the HTTP client into raw Guzzle.

Today it looks like this:

$response = Http::withOptions(['stream' => true])->post($url, $payload);
$body = $response->toPsrResponse()->getBody();

while (! $body->eof()) {
    $line = trim(\GuzzleHttp\Psr7\Utils::readLine($body));
    // ...
}

With this PR:

$response = Http::stream()->post($url, $payload);

foreach ($response->lines() as $line) {
    // ...
}

Quick demo of it in use:

Screen.Recording.2026-04-10.at.8.48.47.AM.mov

@taylorotwell
Copy link
Copy Markdown
Member

Hey @ahinkle - just curious is there a use case where people might actually want the empty lines or new lines returned from a stream?

@ahinkle ahinkle marked this pull request as draft April 20, 2026 13: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.

2 participants