Make request header lookups case-insensitive

Closes #1861
This commit is contained in:
Simon Willison 2026-09-16 10:27:35 -07:00 committed by GitHub
commit df4c0fde0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 63 additions and 4 deletions

View file

@ -26,6 +26,7 @@ Datasette plugins can now use **background tasks** to run code independent of th
Bug fixes
~~~~~~~~~
- :ref:`request.headers <internals_request>` now supports case-insensitive header lookups, so ``request.headers.get("Content-Type")`` works as well as ``request.headers.get("content-type")``. (:issue:`1861`)
- CSV endpoints now return plain-text error messages for SQL errors. (:issue:`2129`)
- The :ref:`render_cell() <plugin_hook_render_cell>` plugin hook now receives an empty ``pks`` list when rendering SQL views in HTML, matching the JSON ``?_extra=render_cell`` behavior. (:issue:`2639`)
- Numeric comparison filters now correctly handle decimal values, negative numbers and scientific notation when filtering computed columns and SQL views. Thanks, `Rami Abdelrazzaq <https://github.com/RamiNoodle733>`__. (:issue:`1681`, :pr:`2876`)

View file

@ -26,7 +26,7 @@ The request object is passed to various plugin hooks. It represents an incoming
The request scheme - usually ``https`` or ``http``.
``.headers`` - dictionary (str -> str)
A dictionary of incoming HTTP request headers. Header names have been converted to lowercase.
A dictionary of incoming HTTP request headers. Header lookups using ``request.headers["Content-Type"]``, ``request.headers.get("Content-Type")`` and ``"Content-Type" in request.headers`` are case-insensitive. Header names are lowercase when iterating over the dictionary.
``.cookies`` - dictionary (str -> str)
A dictionary of incoming cookies