@@ -1272,6 +1272,7 @@ class FetchData(object):
self.basename = None
self.basepath = None
(self.type, self.host, self.path, self.user, self.pswd, self.parm) = decodeurl(d.expand(url))
+ self.headers = None
self.date = self.getSRCDate(d)
self.url = url
if not self.user and "user" in self.parm:
@@ -121,6 +121,10 @@ class Wget(FetchMethod):
# Authorization header.
fetchcmd += " --user=%s --password=%s" % (ud.user, ud.pswd)
+ if ud.headers:
+ for key, value in ud.headers.items():
+ fetchcmd += " --header='%s: %s'" % (key, value)
+
uri = ud.url.split(";")[0]
if os.path.exists(ud.localpath):
# file exists, but we didnt complete it.. trying again..
@@ -394,6 +398,10 @@ class Wget(FetchMethod):
if ud.user and ud.pswd:
add_basic_auth(ud.user + ':' + ud.pswd, r)
+ if ud.headers:
+ for key, value in ud.headers.items():
+ r.add_header(key, value)
+
try:
import netrc
auth_data = netrc.netrc().authenticators(urllib.parse.urlparse(uri).hostname)
This allows derived fetchers to e.g. set a `Authorization: Bearer ...` header for token based authentication, or `Accept:` headers to restrict which file type the fetcher expects. Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de> --- lib/bb/fetch2/__init__.py | 1 + lib/bb/fetch2/wget.py | 8 ++++++++ 2 files changed, 9 insertions(+)