diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2012-09-07 23:40:54 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2012-09-07 23:40:54 -0300 |
commit | 9ca19d7f71f74a81ff3a49ed3e5342b9fb6ba26a (patch) | |
tree | 492c095b9f9305e263a016eb20ef300ff794b471 /src | |
parent | c867912a5a09653dacf9bd691b6dce9f99e9a08a (diff) | |
download | luarocks-9ca19d7f71f74a81ff3a49ed3e5342b9fb6ba26a.tar.gz luarocks-9ca19d7f71f74a81ff3a49ed3e5342b9fb6ba26a.tar.bz2 luarocks-9ca19d7f71f74a81ff3a49ed3e5342b9fb6ba26a.zip |
LuaSocket's http.request crashes when given URLs missing the scheme part.
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/fs/lua.lua | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 6012a454..2231dde5 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
@@ -488,7 +488,15 @@ local redirect_protocols = { | |||
488 | 488 | ||
489 | local function http_request(url, http, loop_control) | 489 | local function http_request(url, http, loop_control) |
490 | local result = {} | 490 | local result = {} |
491 | local res, status, headers, err = http.request { url = url, proxy = cfg.proxy, redirect = false, sink = ltn12.sink.table(result) } | 491 | |
492 | local proxy = cfg.proxy | ||
493 | if type(proxy) ~= "string" then proxy = nil end | ||
494 | -- LuaSocket's http.request crashes when given URLs missing the scheme part. | ||
495 | if proxy and not proxy:find("://") then | ||
496 | proxy = "http://" .. proxy | ||
497 | end | ||
498 | |||
499 | local res, status, headers, err = http.request { url = url, proxy = proxy, redirect = false, sink = ltn12.sink.table(result) } | ||
492 | if not res then | 500 | if not res then |
493 | return nil, status | 501 | return nil, status |
494 | elseif status == 301 or status == 302 then | 502 | elseif status == 301 or status == 302 then |