aboutsummaryrefslogtreecommitdiff
path: root/etc/get.lua
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2004-06-16 22:51:04 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2004-06-16 22:51:04 +0000
commit9fc682a106f13901b60a665619fc61d9dae49fb0 (patch)
tree6efdd73fa4f2abce56b6fb710f7516d0a5c6c758 /etc/get.lua
parent574708380f19b15bd19419bfd64ccbe422f2d924 (diff)
downloadluasocket-9fc682a106f13901b60a665619fc61d9dae49fb0.tar.gz
luasocket-9fc682a106f13901b60a665619fc61d9dae49fb0.tar.bz2
luasocket-9fc682a106f13901b60a665619fc61d9dae49fb0.zip
HTTP now has only one function.
Diffstat (limited to 'etc/get.lua')
-rw-r--r--etc/get.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/etc/get.lua b/etc/get.lua
index 0603ce5..c7e2a43 100644
--- a/etc/get.lua
+++ b/etc/get.lua
@@ -87,9 +87,9 @@ end
87 87
88-- determines the size of a http file 88-- determines the size of a http file
89function gethttpsize(u) 89function gethttpsize(u)
90 local respt = http.request {method = "HEAD", url = u} 90 local r, c, h = http.request {method = "HEAD", url = u}
91 if respt.code == 200 then 91 if c == 200 then
92 return tonumber(respt.headers["content-length"]) 92 return tonumber(h["content-length"])
93 end 93 end
94end 94end
95 95
@@ -98,8 +98,8 @@ function getbyhttp(u, file)
98 local save = ltn12.sink.file(file or io.stdout) 98 local save = ltn12.sink.file(file or io.stdout)
99 -- only print feedback if output is not stdout 99 -- only print feedback if output is not stdout
100 if file then save = ltn12.sink.chain(stats(gethttpsize(u)), save) end 100 if file then save = ltn12.sink.chain(stats(gethttpsize(u)), save) end
101 local respt = http.request {url = u, sink = save } 101 local r, c, h, s = http.request {url = u, sink = save }
102 if respt.code ~= 200 then print(respt.status or respt.error) end 102 if c ~= 200 then io.stderr:write(s or c, "\n") end
103end 103end
104 104
105-- downloads a file using the ftp protocol 105-- downloads a file using the ftp protocol