diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2015-05-19 13:03:31 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2015-05-19 13:03:31 -0300 |
| commit | 5d8a16526573b36d5b22aa74866120c998466697 (patch) | |
| tree | 8e890d09b08980846b6e07dd591c690d0fefacab /src | |
| parent | 4462ca51ee10363916c29c071942c15f424913e6 (diff) | |
| parent | 7b6efb92c092aa00affa8fe63b6226476864c6e3 (diff) | |
| download | luarocks-5d8a16526573b36d5b22aa74866120c998466697.tar.gz luarocks-5d8a16526573b36d5b22aa74866120c998466697.tar.bz2 luarocks-5d8a16526573b36d5b22aa74866120c998466697.zip | |
Merge pull request #371 from ignacio/proxies
Support for configuring proxy via environment variable
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/cfg.lua | 4 | ||||
| -rw-r--r-- | src/luarocks/fs/lua.lua | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 7aaacc76..20aa4a21 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
| @@ -605,6 +605,10 @@ end | |||
| 605 | 605 | ||
| 606 | cfg.user_agent = "LuaRocks/"..cfg.program_version.." "..cfg.arch | 606 | cfg.user_agent = "LuaRocks/"..cfg.program_version.." "..cfg.arch |
| 607 | 607 | ||
| 608 | cfg.http_proxy = os.getenv("http_proxy") | ||
| 609 | cfg.https_proxy = os.getenv("https_proxy") | ||
| 610 | cfg.no_proxy = os.getenv("no_proxy") | ||
| 611 | |||
| 608 | --- Check if platform was detected | 612 | --- Check if platform was detected |
| 609 | -- @param query string: The platform name to check. | 613 | -- @param query string: The platform name to check. |
| 610 | -- @return boolean: true if LuaRocks is currently running on queried platform. | 614 | -- @return boolean: true if LuaRocks is currently running on queried platform. |
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 48db4a0d..c0f6c1c6 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
| @@ -545,7 +545,7 @@ local redirect_protocols = { | |||
| 545 | local function request(url, method, http, loop_control) | 545 | local function request(url, method, http, loop_control) |
| 546 | local result = {} | 546 | local result = {} |
| 547 | 547 | ||
| 548 | local proxy = cfg.proxy | 548 | local proxy = cfg.http_proxy |
| 549 | if type(proxy) ~= "string" then proxy = nil end | 549 | if type(proxy) ~= "string" then proxy = nil end |
| 550 | -- LuaSocket's http.request crashes when given URLs missing the scheme part. | 550 | -- LuaSocket's http.request crashes when given URLs missing the scheme part. |
| 551 | if proxy and not proxy:find("://") then | 551 | if proxy and not proxy:find("://") then |
| @@ -653,6 +653,11 @@ function fs_lua.download(url, filename, cache) | |||
| 653 | assert(type(filename) == "string" or not filename) | 653 | assert(type(filename) == "string" or not filename) |
| 654 | 654 | ||
| 655 | filename = fs.absolute_name(filename or dir.base_name(url)) | 655 | filename = fs.absolute_name(filename or dir.base_name(url)) |
| 656 | |||
| 657 | -- delegate to the configured downloader so we don't have to deal with whitelists | ||
| 658 | if cfg.no_proxy then | ||
| 659 | return fs.use_downloader(url, filename, cache) | ||
| 660 | end | ||
| 656 | 661 | ||
| 657 | local content, err, https_err | 662 | local content, err, https_err |
| 658 | if util.starts_with(url, "http:") then | 663 | if util.starts_with(url, "http:") then |
| @@ -660,7 +665,8 @@ function fs_lua.download(url, filename, cache) | |||
| 660 | elseif util.starts_with(url, "ftp:") then | 665 | elseif util.starts_with(url, "ftp:") then |
| 661 | content, err = ftp.get(url) | 666 | content, err = ftp.get(url) |
| 662 | elseif util.starts_with(url, "https:") then | 667 | elseif util.starts_with(url, "https:") then |
| 663 | if luasec_ok then | 668 | -- skip LuaSec when proxy is enabled since it is not supported |
| 669 | if luasec_ok and not cfg.https_proxy then | ||
| 664 | content, err = http_request(url, https, cache and filename) | 670 | content, err = http_request(url, https, cache and filename) |
| 665 | else | 671 | else |
| 666 | https_err = true | 672 | https_err = true |
