diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2012-10-16 23:29:19 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2012-10-16 23:29:19 -0300 |
commit | 5c17b07c4d70d459d512cb10db233bbf847a44c1 (patch) | |
tree | fb0c29837aac96ab475538b84fbbe4d0ebd9b9e3 /src | |
parent | e51efb721935e959b33c6ec9884d2ecbe418fcb2 (diff) | |
download | luarocks-5c17b07c4d70d459d512cb10db233bbf847a44c1.tar.gz luarocks-5c17b07c4d70d459d512cb10db233bbf847a44c1.tar.bz2 luarocks-5c17b07c4d70d459d512cb10db233bbf847a44c1.zip |
Report LuaRocks user-agent when using LuaSocket as well.
Report also architecture and downloader tool, so we gather some general stats.
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/cfg.lua | 3 | ||||
-rw-r--r-- | src/luarocks/fs/lua.lua | 10 | ||||
-rw-r--r-- | src/luarocks/fs/unix/tools.lua | 4 | ||||
-rw-r--r-- | src/luarocks/fs/win32/tools.lua | 4 |
4 files changed, 15 insertions, 6 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 00c4aea0..d4222998 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
@@ -26,7 +26,6 @@ _M.site_config = site_config | |||
26 | 26 | ||
27 | lua_version = _VERSION:sub(5) | 27 | lua_version = _VERSION:sub(5) |
28 | program_version = "2.0.11" | 28 | program_version = "2.0.11" |
29 | user_agent = "LuaRocks/"..program_version | ||
30 | 29 | ||
31 | local persist = require("luarocks.persist") | 30 | local persist = require("luarocks.persist") |
32 | 31 | ||
@@ -438,6 +437,8 @@ function which_config() | |||
438 | return sys_config_file, sys_config_ok, home_config_file, home_config_ok | 437 | return sys_config_file, sys_config_ok, home_config_file, home_config_ok |
439 | end | 438 | end |
440 | 439 | ||
440 | user_agent = "LuaRocks/"..program_version.." "..arch | ||
441 | |||
441 | --- Check if platform was detected | 442 | --- Check if platform was detected |
442 | -- @param query string: The platform name to check. | 443 | -- @param query string: The platform name to check. |
443 | -- @return boolean: true if LuaRocks is currently running on queried platform. | 444 | -- @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 24b05a59..00c576dc 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
@@ -501,7 +501,15 @@ local function http_request(url, http, loop_control) | |||
501 | proxy = "http://" .. proxy | 501 | proxy = "http://" .. proxy |
502 | end | 502 | end |
503 | 503 | ||
504 | local res, status, headers, err = http.request { url = url, proxy = proxy, redirect = false, sink = ltn12.sink.table(result) } | 504 | local res, status, headers, err = http.request { |
505 | url = url, | ||
506 | proxy = proxy, | ||
507 | redirect = false, | ||
508 | sink = ltn12.sink.table(result), | ||
509 | headers = { | ||
510 | ["user-agent"] = cfg.user_agent.." via LuaSocket" | ||
511 | }, | ||
512 | } | ||
505 | if not res then | 513 | if not res then |
506 | return nil, status | 514 | return nil, status |
507 | elseif status == 301 or status == 302 then | 515 | elseif status == 301 or status == 302 then |
diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua index 7e29fc0a..3b853be7 100644 --- a/src/luarocks/fs/unix/tools.lua +++ b/src/luarocks/fs/unix/tools.lua | |||
@@ -237,7 +237,7 @@ function download(url, filename) | |||
237 | assert(type(filename) == "string" or not filename) | 237 | assert(type(filename) == "string" or not filename) |
238 | 238 | ||
239 | if cfg.downloader == "wget" then | 239 | if cfg.downloader == "wget" then |
240 | local wget_cmd = vars.WGET.." --no-check-certificate --no-cache --user-agent="..cfg.user_agent.." --quiet --continue " | 240 | local wget_cmd = vars.WGET.." --no-check-certificate --no-cache --user-agent='"..cfg.user_agent.." via wget' --quiet --continue " |
241 | if filename then | 241 | if filename then |
242 | return fs.execute(wget_cmd.." --output-document ", filename, url) | 242 | return fs.execute(wget_cmd.." --output-document ", filename, url) |
243 | else | 243 | else |
@@ -245,7 +245,7 @@ function download(url, filename) | |||
245 | end | 245 | end |
246 | elseif cfg.downloader == "curl" then | 246 | elseif cfg.downloader == "curl" then |
247 | filename = filename or dir.base_name(url) | 247 | filename = filename or dir.base_name(url) |
248 | return fs.execute_string(vars.CURL.." -L --user-agent "..cfg.user_agent.." "..fs.Q(url).." 2> /dev/null 1> "..fs.Q(filename)) | 248 | return fs.execute_string(vars.CURL.." -L --user-agent '"..cfg.user_agent.." via curl' "..fs.Q(url).." 2> /dev/null 1> "..fs.Q(filename)) |
249 | end | 249 | end |
250 | end | 250 | end |
251 | 251 | ||
diff --git a/src/luarocks/fs/win32/tools.lua b/src/luarocks/fs/win32/tools.lua index 48eca64b..3e7ebd32 100644 --- a/src/luarocks/fs/win32/tools.lua +++ b/src/luarocks/fs/win32/tools.lua | |||
@@ -246,7 +246,7 @@ function download(url, filename) | |||
246 | assert(type(filename) == "string" or not filename) | 246 | assert(type(filename) == "string" or not filename) |
247 | 247 | ||
248 | if cfg.downloader == "wget" then | 248 | if cfg.downloader == "wget" then |
249 | local wget_cmd = vars.WGET.." --no-check-certificate --no-cache --user-agent="..cfg.user_agent.." --quiet --continue " | 249 | local wget_cmd = vars.WGET.." --no-check-certificate --no-cache --user-agent=\""..cfg.user_agent.." via wget\" --quiet --continue " |
250 | if filename then | 250 | if filename then |
251 | return fs.execute(wget_cmd.." --output-document ", filename, url) | 251 | return fs.execute(wget_cmd.." --output-document ", filename, url) |
252 | else | 252 | else |
@@ -254,7 +254,7 @@ function download(url, filename) | |||
254 | end | 254 | end |
255 | elseif cfg.downloader == "curl" then | 255 | elseif cfg.downloader == "curl" then |
256 | filename = filename or dir.base_name(url) | 256 | filename = filename or dir.base_name(url) |
257 | return fs.execute_string(vars.CURL.." -L --user-agent "..cfg.user_agent.." "..fs.Q(url).." 2> NUL 1> "..fs.Q(filename)) | 257 | return fs.execute_string(vars.CURL.." -L --user-agent \""..cfg.user_agent.." via curl\" "..fs.Q(url).." 2> NUL 1> "..fs.Q(filename)) |
258 | end | 258 | end |
259 | end | 259 | end |
260 | 260 | ||