Skip to content
Myr

change make_response to use headers.update

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Christopher Nguyen · committed by David Lord · parent 6f2fdc5 · Browse files · 3 files+15 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+15 added−7 removed

  • tests:+6 added−3 removed
  • other:+9 added−4 removed

3 files+15 added−7 removed

modified:src/flask/app.py+1 added-1 removed
2043 unmodified lines
2044 rv.status_code = status20452046 # extend existing headers with provided headers2047 if headers:2048 rv.headers.extend(headers)2048 rv.headers.update(headers)20492050 return rv20512052 def create_url_adapter(self, request):
321 unmodified lines
modified:tests/test_basic.py+6 added-3 removed
1115 unmodified lines
11161117 @app.route("/response_headers")1118 def from_response_headers():1119 return (1120 flask.Response("Hello world", 404, {"X-Foo": "Baz"}),1121 {"X-Foo": "Bar", "X-Bar": "Foo"},1120 flask.Response(1121 "Hello world", 404, {"Content-Type": "text/html", "X-Foo": "Baz"}1122 ),1123 {"Content-Type": "text/plain", "X-Foo": "Bar", "X-Bar": "Foo"},1124 )11251126 @app.route("/response_status")1127 def from_response_status():
28 unmodified lines
1156 assert rv.mimetype == "text/html"11571158 rv = client.get("/response_headers")1159 assert rv.data == b"Hello world"1160 assert rv.content_type == "text/plain"1158 assert rv.headers.getlist("X-Foo") == ["Baz", "Bar"]1161 assert rv.headers.getlist("X-Foo") == ["Bar"]1162 assert rv.headers["X-Bar"] == "Foo"1163 assert rv.status_code == 40411641165 rv = client.get("/response_status")
807 unmodified lines
modified:CHANGES.rst+8 added-3 removed
25 unmodified lines
26- When using ad-hoc certificates, check for the cryptography library27 instead of PyOpenSSL. :pr:`3492`28- When specifying a factory function with ``FLASK_APP``, keyword29 argument can be passed. :issue:`3553`30- When loading a ``.env`` or ``.flaskenv`` file on top level directory,31 Flask will not change current work directory to the location of dotenv32 files, in order to prevent potential confusion. :pr:`3560`30- When loading a ``.env`` or ``.flaskenv`` file, the current working31 directory is no longer changed to the location of the file.32 :pr:`3560`33- When returning a ``(response, headers)`` tuple from a view, the34 headers replace rather than extend existing headers on the response.35 For example, this allows setting the ``Content-Type`` for36 ``jsonify()``. Use ``response.headers.extend()`` if extending is37 desired. :issue:`3628`383940Version 1.1.x41-------------
1020 unmodified lines