-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Propagate HTTPClient.Task<Response>
failures to subsequent redirect tasks
#814
Propagate HTTPClient.Task<Response>
failures to subsequent redirect tasks
#814
Conversation
Should |
We avoid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've taken a look.
First, I really like this patch @gregcotten. You've done a good job of threading this nicely through the code, and followed all the existing coding style. It's really rare to get contributors who do such a great job of that, so I wanted to express my appreciation.
Secondly, though, I wonder if we can make this simpler. I think the mere presence of a redirect task is sufficient to indicate that we need to cancel that task, as well as ourselves. So should we just unilaterally forward it on?
Relatedly, we need to ensure we only look at the redirect task while holding the lock.
Thanks so much! I'm trying my best to follow the style 🕵
So remove Something as simple as this? The fail action was private func fail0(_ error: Error) {
self.task.eventLoop.assertInEventLoop()
let action = self.state.fail(error)
self.executeFailAction0(action)
self.redirectTask?.cancel()
}
Currently it's only being assigned when on self.task.eventLoop.assertInEventLoop() |
Yes, modulo the lock.
Right, but it's read from anywhere. So we need the lock. |
As for the test, I think the right solution here is to rely on a httpbin endpoint with a long delay, plus a redirect. (The httpbin stuff is internal to the project) You can use |
Actually re-reading this, I'm not sure I understand. I've made |
Oh I apologise, you're quite right. I am clearly losing my mind here. |
OK, @Lukasa, ready! |
Only last minute thought is that instead of simply propagating cancellation, we propagate the actual |
Yeah, let's propagate the fail. |
OK @Lukasa, done and ready to go. |
Task
cancellation through subsequent redirectsHTTPClient.Task<Response>
failures to subsequent redirect tasks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, I think this is looking really good.
Discussed in #753
No test yet, and would love advice on how to best make one...