Skip to content

[HttpClient] Getting responses asynchronously as soon as they ready #32142

@TiGR

Description

@TiGR

Here is the deal: I use Symfony and HttpClient in telegram bot. Bot sends various requests to Telegram's API, and most of these I don't really care to get the response in main bot logic (I want to run the code as fast as possible). However, I'd like to add requests and responses to Sentry breadcrumbs for reporting. Adding requests is easy. Adding responses is tricky.

I don't want actually to call Response->getContent(), so that it would stop main logic execution until I get the response. However, I'd like to somehow get notified as soon as response is ready. Then, I'd like to add the response to breadcrumbs, and then if there were errors in responses - send a notification.

I've tried subscribing to on_progress, but that didn't work, since responses were not ready when I tried using them from that callback.

So, I couldn't find anything about some sort of event system, so that I could subscribe and get responses as soon as they get ready. Is it really possible? And if not, then it's a feature request, I guess...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions