File: header-name-case.rst

package info (click to toggle)
python-falcon 4.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,172 kB
  • sloc: python: 33,608; javascript: 92; sh: 50; makefile: 50
file content (22 lines) | stat: -rw-r--r-- 770 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
.. _capitalizing_response_headers:

Capitalizing Response Header Names
==================================

Falcon always renders WSGI response header names in lower case; see
also: :ref:`faq_header_names_lowercase`

While this should normally never be an issue for standards-conformant HTTP
clients, it is possible to override HTTP headers using
`generic WSGI middleware
<https://www.python.org/dev/peps/pep-3333/#middleware-components-that-play-both-sides>`_:

.. literalinclude:: ../../../examples/recipes/header_name_case_mw.py
    :language: python

We can now use this middleware to wrap a Falcon app:

.. literalinclude:: ../../../examples/recipes/header_name_case_app.py
    :language: python

As a bonus, this recipe applies to non-Falcon WSGI applications too.