From 432da12f478af5fad27a06377ee85f587cf8f005 Mon Sep 17 00:00:00 2001 From: Atlas Cove Date: Sun, 12 Dec 2021 06:41:15 +0000 Subject: [PATCH] Initial Commit --- .gitignore | 5 +++++ snarf-dev-1.rockspec | 19 +++++++++++++++++++ snarf.lua | 15 +++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 .gitignore create mode 100644 snarf-dev-1.rockspec create mode 100644 snarf.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..220db6b --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/luarocks +/lua +/lua_modules +/.luarocks +*.luac diff --git a/snarf-dev-1.rockspec b/snarf-dev-1.rockspec new file mode 100644 index 0000000..86b1e41 --- /dev/null +++ b/snarf-dev-1.rockspec @@ -0,0 +1,19 @@ +package = "snarf" +version = "dev-1" +source = { + url = nil +} +description = { + homepage = "https://github.com/Atlas48/snarf-lua", + license = "LGPL-3.0-or-later" +} +dependencies = { + "lua >= 5.1", + "luasocket >= 3.0rc1-2" +} +build = { + type = "builtin", + modules = { + snarf = "snarf.lua" + } +} diff --git a/snarf.lua b/snarf.lua new file mode 100644 index 0000000..a3eaf54 --- /dev/null +++ b/snarf.lua @@ -0,0 +1,15 @@ +local http=require "socket.http" +function snarf(s,l) + local body,code=http.request(s) + if code<=400 or code>=599 then + error(code) + elseif code<=300 or code>=399 then + print("Redirects not currently implemented") + error(code) + end + + local f=assert(io.open(l)) + f:write(body) + f:close() +end +return snarf