diff --git a/gunicorn_config.py b/gunicorn_config.py index f7ca6160e..5ed520afb 100644 --- a/gunicorn_config.py +++ b/gunicorn_config.py @@ -16,18 +16,6 @@ gunicorn.SERVER_SOFTWARE = "None" def on_starting(server): server.log.info("Starting Notifications API") - from gunicorn.http.wsgi import Response - - original_init = Response.__init__ - - def custom_init(self, *args, **kwargs): - original_init(self, *args, **kwargs) - self.headers = [ - (key, value) for key, value in self.headers if key.lower() != "server" - ] - print(f"HEADERS {self.headers}") - - Response.__init__ = custom_init def worker_abort(worker): @@ -44,6 +32,24 @@ def worker_int(worker): worker.log.info("worker: received SIGINT {}".format(worker.pid)) +# fix dynamic scan warning 10036 +def post_fork(server, worker): + server.cfg.set( + "secure_scheme_headers", + { + "X-FORWARDED-PROTO": "https", + }, + ) + original_send = worker.wsgi.send + + def custom_send(self, resp, *args, **kwargs): + resp.headers.pop("Server", None) + print(f"HEADERS!!!!!!!! {resp.headers}") + return original_send(resp, *args, **kwargs) + + worker.wsgi.send = custom_send.__get__(worker.wsgi, type(worker.wsgi)) + + def fix_ssl_monkeypatching(): """ eventlet works by monkey-patching core IO libraries (such as ssl) to be non-blocking. However, there's currently diff --git a/notifications_utils/request_helper.py b/notifications_utils/request_helper.py index b0f34471e..3e89255f4 100644 --- a/notifications_utils/request_helper.py +++ b/notifications_utils/request_helper.py @@ -93,7 +93,7 @@ class ResponseHeaderMiddleware(object): found_a_text_yaml = True if found_a_text_yaml: - headers.append(("Content-Type", "application/yaml")) + headers.append(("Content-Type", "text/plain")) print(headers) return start_response(status, headers, exc_info)