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

How do I cancel an already accepted push promise? #243

Closed
nicolas-grekas opened this issue Jan 3, 2020 · 3 comments
Closed

How do I cancel an already accepted push promise? #243

nicolas-grekas opened this issue Jan 3, 2020 · 3 comments

Comments

@nicolas-grekas
Copy link
Contributor

@nicolas-grekas nicolas-grekas commented Jan 3, 2020

In my use case, I accept all HTTP/2 push promises and put them in a temporary cache.
After some time, I want to cancel the ones that have not been used yet.
I didn't find a way to do so, did I miss something?
Thanks for the help :)

@trowski

This comment has been minimized.

Copy link
Member

@trowski trowski commented Jan 3, 2020

You can throw a Amp\CancelledException or an Amp\Http\Client\HttpException from the push promise handler to cancel the push promise.

@nicolas-grekas

This comment has been minimized.

Copy link
Contributor Author

@nicolas-grekas nicolas-grekas commented Jan 3, 2020

You can throw from the push promise handler

I spotted that, but I'm not sure that answers my use case. Maybe it's me not being fluent enough with amp.
Inside the push handler, I store pushed req+response-promise in a queue.
Then, later on, I consume from the queue. And from time to time, I want to empty the queue.
Could the push handler be given a 3rd argument: a cancellation source that we could use to cancel the pushed req/resp when needed later on?

@trowski

This comment has been minimized.

Copy link
Member

@trowski trowski commented Jan 3, 2020

Funny you should suggest a cancellation token source as a third argument, since that's how I originally wrote that function. @kelunik I think we should add that back.

trowski added a commit that referenced this issue Jan 6, 2020
Related to #243.
trowski added a commit that referenced this issue Jan 13, 2020
Related to #243.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.