falconry / falcon

The no-magic web data plane API and microservices framework for Python developers, with a focus on reliability, correctness, and performance at scale.
https://falcon.readthedocs.io/en/stable/
Apache License 2.0
9.51k stars 935 forks source link

Full response content-type negotiation #2029

Open vytas7 opened 2 years ago

vytas7 commented 2 years ago

At the time of writing, we don't support full response content-type negotiation:

The missing link that Falcon doesn’t provide is the connection between the Accept header provided by a user and the Content-Type header set on the response.

"Full negotiation" means that we should pick one media type from the response handlers that best matches req.accept, and set resp.content_type to it (and not just do a naive resp.content_type = req.accept which would potentially set it to a bunch of multiple types or even wildcards).

In order to avoid a breaking change, this could be governed by the response options (and potentially enabled by default in a subsequent stable release).

vytas7 commented 1 month ago

We'll probably need to make this optional anyway or introduce in a non-breaking way in order to avoid disrupting people's code. Rescheduling to 4.1 since we won't have much time for 4.0.