Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Http data collection consumes response stream without resetting it #727

Open
mikethea1 opened this issue Jan 2, 2025 · 0 comments
Open

Comments

@mikethea1
Copy link

I have some laravel code that is making an HTTP request like so:

Http::get(...)->getBody()->getContents();

With clockwork enabled, this starts returning empty string (took a long time to track down the root cause). I tracked this down to LaravelHttpClientDataSource, which by default consumes the request body.

I feel like clockwork should strive to have no observable side-effects. In this case, I think the solution could be some additional logic to reset the stream. Something like this:

$body = $response->getBody();
if (!$body->isSeekable()) { return null; } // not safe to collect
$position = $body->tell();
// obviously need to integrate the enabled checks for these
$rawContent = $body->toString();
$json = $response->json();
$body->seek($position); // restore the original position
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

No branches or pull requests

1 participant