|
3 | 3 | from aiohttp import ClientResponseError, ClientError |
4 | 4 | from lxml.etree import LxmlError |
5 | 5 | from gettext import gettext as _ |
| 6 | +from functools import partial |
6 | 7 |
|
7 | 8 | from rest_framework import serializers |
8 | 9 |
|
| 10 | +from pulpcore.plugin.download import HttpDownloader |
9 | 11 | from pulpcore.plugin.models import Artifact, ProgressReport, Remote, Repository |
10 | 12 | from pulpcore.plugin.stages import ( |
11 | 13 | DeclarativeArtifact, |
@@ -112,11 +114,22 @@ async def run(self): |
112 | 114 | """ |
113 | 115 | # Bandersnatch includes leading slash when forming API urls |
114 | 116 | url = self.remote.url.rstrip("/") |
| 117 | + downloader = self.remote.get_downloader(url=url) |
| 118 | + if not isinstance(downloader, HttpDownloader): |
| 119 | + raise ValueError("Only HTTP(S) is supported for python syncing") |
| 120 | + |
115 | 121 | async with Master(url) as master: |
116 | 122 | # Replace the session with the remote's downloader session |
117 | 123 | old_session = master.session |
118 | | - factory = self.remote.download_factory |
119 | | - master.session = factory._session |
| 124 | + master.session = downloader.session |
| 125 | + |
| 126 | + # Set up master.get with remote's auth & proxy settings |
| 127 | + master.get = partial( |
| 128 | + master.get, |
| 129 | + auth=downloader.auth, |
| 130 | + proxy=downloader.proxy, |
| 131 | + proxy_auth=downloader.proxy_auth, |
| 132 | + ) |
120 | 133 |
|
121 | 134 | deferred_download = self.remote.policy != Remote.IMMEDIATE |
122 | 135 | workers = self.remote.download_concurrency or self.remote.DEFAULT_DOWNLOAD_CONCURRENCY |
|
0 commit comments