diff options
| author | ruki <[email protected]> | 2023-02-04 10:32:59 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-02-04 10:32:59 +0800 |
| commit | 33f3591b69efa70eb77211cc7c937e0cde054de9 (patch) | |
| tree | 2e34856609d96aefd158433039b51289113128ce | |
| parent | 1d916603e8ab705f4af9b0a14d9fa2bfc620dfaf (diff) | |
add http header to package
4 files changed, 11 insertions, 3 deletions
diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua index 1a466aa68..52f13c9b7 100644 --- a/xmake/core/project/policy.lua +++ b/xmake/core/project/policy.lua @@ -76,6 +76,8 @@ function policy.policies() ["package.install_only"] = {description = "Only install packages from remote.", type = "boolean"}, -- always install packages every time ["package.install_always"] = {description = "Always install packages every time.", type = "boolean"}, + -- set custom headers when downloading package + ["package.download.http_headers"] = {description = "Set the custom http headers when downloading package."}, -- use includes as external header files? e.g. -isystem .. ["package.include_external_headers"] = {description = "Use includes as external headers.", type = "boolean"}, -- inherit the configs from the external command arguments, e.g. toolchains, `xmake f --toolchain=` diff --git a/xmake/modules/private/action/require/impl/actions/download.lua b/xmake/modules/private/action/require/impl/actions/download.lua index f6070021d..336d07211 100644 --- a/xmake/modules/private/action/require/impl/actions/download.lua +++ b/xmake/modules/private/action/require/impl/actions/download.lua @@ -164,7 +164,9 @@ function _download(package, url, sourcedir, url_alias, url_excludes) -- we can use local package from the search directories directly if network is too slow os.cp(localfile, packagefile) else - http.download(url, packagefile, {insecure = global.get("insecure-ssl")}) + http.download(url, packagefile, { + insecure = global.get("insecure-ssl"), + headers = package:policy("package.download.http_headers")}) end end diff --git a/xmake/modules/private/action/require/impl/actions/download_resources.lua b/xmake/modules/private/action/require/impl/actions/download_resources.lua index 5373fd81f..a62d3a3af 100644 --- a/xmake/modules/private/action/require/impl/actions/download_resources.lua +++ b/xmake/modules/private/action/require/impl/actions/download_resources.lua @@ -114,7 +114,9 @@ function _download(package, resource_name, resource_url, resource_hash) -- we can use local resource from the search directories directly if network is too slow os.cp(localfile, resource_file) elseif resource_url:find(string.ipattern("https-://")) or resource_url:find(string.ipattern("ftps-://")) then - http.download(resource_url, resource_file, {insecure = global.get("insecure-ssl")}) + http.download(resource_url, resource_file, { + insecure = global.get("insecure-ssl"), + headers = package:policy("package.download.http_headers")}) else raise("invalid resource url(%s)", resource_url) end diff --git a/xmake/modules/private/action/require/impl/actions/patch_sources.lua b/xmake/modules/private/action/require/impl/actions/patch_sources.lua index 10b89c911..cef9aa692 100644 --- a/xmake/modules/private/action/require/impl/actions/patch_sources.lua +++ b/xmake/modules/private/action/require/impl/actions/patch_sources.lua @@ -73,7 +73,9 @@ function _patch(package, patch_url, patch_hash) -- download the patch file if patch_url:find(string.ipattern("https-://")) or patch_url:find(string.ipattern("ftps-://")) then - http.download(patch_url, patch_file) + http.download(patch_url, patch_file, { + insecure = global.get("insecure-ssl"), + headers = package:policy("package.download.http_headers")}) else -- copy the patch file if os.isfile(patch_url) then |
