Skip to content

Commit

Permalink
Merge pull request #1628 from dmach/fix-conf-http_headers
Browse files Browse the repository at this point in the history
Use configured 'http_headers' in HTTP requests
  • Loading branch information
dmach authored Sep 16, 2024
2 parents 0302053 + 55a5cb1 commit 0b93cfc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions osc/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 0b93cfc

Please sign in to comment.