diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2011-04-21 20:03:30 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2011-04-21 20:03:30 -0300 |
commit | 12376262d2ae7814f13596fd1cf24def4875a836 (patch) | |
tree | a60596064e914561b76eea703a726af1591d7b47 | |
parent | 3f9ef49e926b3576f49682273b84034d704eaabe (diff) | |
download | luarocks-12376262d2ae7814f13596fd1cf24def4875a836.tar.gz luarocks-12376262d2ae7814f13596fd1cf24def4875a836.tar.bz2 luarocks-12376262d2ae7814f13596fd1cf24def4875a836.zip |
Support redirects from https to http, fixes issue with bitbucket.org URLs.
-rw-r--r-- | src/luarocks/fs/lua.lua | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 72e7b022..0a748b0e 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
@@ -485,18 +485,10 @@ local redirect_protocols = { | |||
485 | } | 485 | } |
486 | 486 | ||
487 | local function http_request(url, http, loop_control) | 487 | local function http_request(url, http, loop_control) |
488 | local proxy = cfg.proxy | 488 | local result = {} |
489 | local url_arg, proxy_result | 489 | local res, status, headers, err = http.request { url = url, proxy = cfg.proxy, redirect = false, sink = ltn12.sink.table(result) } |
490 | if proxy then | ||
491 | proxy_result = {} | ||
492 | url_arg = { url = url, proxy = proxy, sink = ltn12.sink.table(proxy_result) } | ||
493 | else | ||
494 | url_arg = url | ||
495 | end | ||
496 | local res, status, headers, line = http.request(url_arg) | ||
497 | local content, err | ||
498 | if not res then | 490 | if not res then |
499 | err = status | 491 | return nil, status |
500 | elseif status == 301 or status == 302 then | 492 | elseif status == 301 or status == 302 then |
501 | local location = headers.location | 493 | local location = headers.location |
502 | if location then | 494 | if location then |
@@ -513,14 +505,12 @@ local function http_request(url, http, loop_control) | |||
513 | return nil, "URL redirected to unsupported protocol - install luasec to get HTTPS support." | 505 | return nil, "URL redirected to unsupported protocol - install luasec to get HTTPS support." |
514 | end | 506 | end |
515 | end | 507 | end |
516 | err = line | 508 | return nil, err |
517 | elseif status ~= 200 then | 509 | elseif status ~= 200 then |
518 | err = line | 510 | return nil, err |
519 | else | 511 | else |
520 | if proxy_result then res = table.concat(proxy_result) end | 512 | return table.concat(result) |
521 | content = res | ||
522 | end | 513 | end |
523 | return content, err | ||
524 | end | 514 | end |
525 | 515 | ||
526 | --- Download a remote file. | 516 | --- Download a remote file. |