1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-08 13:56:15 +01:00

Merge pull request #1628 from dmach/fix-conf-http_headers

Use configured 'http_headers' in HTTP requests
This commit is contained in:
Daniel Mach 2024-09-16 09:34:30 +02:00 committed by GitHub
commit 0b93cfc7c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -220,6 +220,14 @@ def http_request(method: str, url: str, headers=None, data=None, file=None):
options = conf.config["api_host_options"][apiurl] 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 global CONNECTION_POOLS
pool = CONNECTION_POOLS.get(apiurl, None) pool = CONNECTION_POOLS.get(apiurl, None)
if not pool: if not pool: