Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Use Downloader.extra_headers instead of session.headers
In recent change in nectar session in downloader was removed from
shared space for all threads and for every request new Session
object is created. To be able to provide same functionality
extra_headers dictionary was added to Downloader object. This commit
modifies code to use extra_headers instead of session.headers
  • Loading branch information
midnightercz committed Jul 23, 2020
1 parent e4bf4ed commit 859ae55
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion plugins/pulp_docker/plugins/auth_util.py
Expand Up @@ -90,7 +90,7 @@ def request_token(downloader, request, auth_header, repo_name):
token_data = StringIO()
token_request = DownloadRequest(token_url, token_data)
_logger.debug("Requesting token from {url}".format(url=token_url))
downloader.session.headers.pop('Authorization', None)
downloader.extra_headers.pop('Authorization', None)
report = downloader.download_one(token_request)
if report.state == report.DOWNLOAD_FAILED:
return report
Expand Down
8 changes: 4 additions & 4 deletions plugins/pulp_docker/plugins/importers/sync.py
Expand Up @@ -454,16 +454,16 @@ def download_failed(self, report):
if auth_header is None:
raise IOError("401 responses are expected to contain authentication information")
if "Basic" in auth_header:
self.downloader.session.headers = auth_util.update_basic_auth_header(
self.downloader.session.headers,
self.downloader.extra_headers = auth_util.update_basic_auth_header(
self.downloader.extra_headers,
self.basic_auth_username, self.basic_auth_password)
_logger.debug(_('Download unauthorized, retrying with basic authentication'))
else:
token = auth_util.request_token(self.parent.index_repository.auth_downloader,
request, auth_header,
self.parent.index_repository.name)
self.downloader.session.headers = auth_util.update_token_auth_header(
self.downloader.session.headers, token)
self.downloader.extra_headers = auth_util.update_token_auth_header(
self.downloader.extra_headers, token)
_logger.debug("Download unauthorized, retrying with new bearer token.")

# Events must be false or download_failed will recurse
Expand Down

0 comments on commit 859ae55

Please sign in to comment.