Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Beginning with 2.0.0, Werkzeug started identifying incoming websocket requests, and only matching them to rules that are marked as being websocket targets. See pallets/werkzeug#2052.
This breaks Nameko's websocket functionality which defines some rules that were not marked as being websocket targets, which thus no longer match, resulting in a 400 error. With Werkzeug 2x it is sufficient to simply mark these rules as being websocket targets, but this results in a 400 error Werkzeug 1x for the same reason -- no rule matches the type of request framework determines the request to be.
This PR makes the explicit identification of a rule as a websocket target conditional on the version of Werkzeug. Furthermore, in Werkzeug < 1.0.0 the Rule constructor doesn't even accept the
websocket
argument, so this PR also drops support for those versions.Alternatives to the approach taken here are:
websocket=False
intoadapter.match()
)The conditional is the most explicit solution and is easily removed if we decide to drop support for Werkzeug 1.x in the future.