Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use configured 'http_headers' in HTTP requests #1628

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading