With the new NIOTypedWebSocketServerUpgrader
there doesn't appear to be anyway to tell the difference between a server upgrade that failed because the shouldUpgrade
method returned nil
and a HTTP request that doesn't ask for an upgrade. They both end up calling the notUpgradingCompletionHandler
in NIOTypedHTTPServerUpgradeConfiguration
.
NIOTypedHTTPServerUpgradeConfiguration, difference between failed upgrade and not request an upgrade
I think this design was motivated by the idea that you know that the upgrade failed due to you rejecting it: the callback was yours. But yeah, we could probably provide a set of APIs that handles that better. Mind filing an issue?
Problem is at the point I am failing the server upgrade I don't really have any way to pass back the fact I attempted and failed it. I guess I could capture a reference value in the closure and then set a boolean inside that, but that isn't a particularly nice way to do it, plus it will require an additional allocation.
Now I've looked into this I've found my original pre-concurrency websocket code, only worked by fluke. An upgrade failed error is passed up the channel pipeline and I catch that and return an HTTP error because of that.
I'll add the issue