@@ -121,6 +121,9 @@ class Wget(FetchMethod):
# Authorization header.
fetchcmd += " --user=%s --password=%s" % (ud.user, ud.pswd)
+ for key, value in getattr(ud, "http_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 +397,9 @@ class Wget(FetchMethod):
if ud.user and ud.pswd:
add_basic_auth(ud.user + ':' + ud.pswd, r)
+ for key, value in getattr(ud, "http_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/wget.py | 6 ++++++ 1 file changed, 6 insertions(+)