From 55a5cb1fc540426b72a96118788059ce39649c8e Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Mon, 16 Sep 2024 08:26:15 +0200 Subject: [PATCH] Use configured 'http_headers' in HTTP requests --- osc/connection.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/osc/connection.py b/osc/connection.py index 379799a7d..2ffbcb3ef 100644 --- a/osc/connection.py +++ b/osc/connection.py @@ -220,6 +220,14 @@ def http_request(method: str, url: str, headers=None, data=None, file=None): options = conf.config["api_host_options"][apiurl] + if options.http_headers: + new_headers = urllib3.response.HTTPHeaderDict() + # user-defined headers from the config file + new_headers.update(options.http_headers) + # original ``headers`` (Content-Length, User-Agent) must prevail over user-defined headers + new_headers.update(headers) + headers = new_headers + global CONNECTION_POOLS pool = CONNECTION_POOLS.get(apiurl, None) if not pool: