mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-12 16:22:17 -05:00
fix content-type conditionally
This commit is contained in:
@@ -81,17 +81,21 @@ class ResponseHeaderMiddleware(object):
|
|||||||
for key, value in headers
|
for key, value in headers
|
||||||
if key.lower() not in ["server", "last-modified"]
|
if key.lower() not in ["server", "last-modified"]
|
||||||
]
|
]
|
||||||
|
found_a_text_yaml = False
|
||||||
|
old_headers_len = len(headers)
|
||||||
headers = [
|
headers = [
|
||||||
(key, value)
|
(key, value)
|
||||||
for key, value in headers
|
for key, value in headers
|
||||||
if "werkzeug" not in value.lower()
|
if "text/yaml" not in value.lower()
|
||||||
]
|
]
|
||||||
|
new_headers_len = len(headers)
|
||||||
|
if new_headers_len < old_headers_len:
|
||||||
|
found_a_text_yaml = True
|
||||||
|
|
||||||
for key, value in headers:
|
if found_a_text_yaml:
|
||||||
if key.lower() == "content-type" and "text/yaml" in value.lower():
|
headers.append(("Content-Type", "application/yaml"))
|
||||||
headers.pop("Content-Type")
|
|
||||||
headers.append("Content-Type", "application/yaml")
|
print(headers)
|
||||||
headers.append(("Server", "SecureServer"))
|
|
||||||
return start_response(status, headers, exc_info)
|
return start_response(status, headers, exc_info)
|
||||||
|
|
||||||
return self._app(environ, rewrite_response_headers)
|
return self._app(environ, rewrite_response_headers)
|
||||||
|
|||||||
Reference in New Issue
Block a user