libs: move http.protocol.{date,mime,conditionals} to luci-lib-httpprotoutils
authorJo-Philipp Wich <redacted>
Wed, 18 Apr 2018 13:49:26 +0000 (15:49 +0200)
committerJo-Philipp Wich <redacted>
Wed, 18 Apr 2018 14:21:27 +0000 (16:21 +0200)
Also adjust the dependencies of components depending on these classes and
flatten the namespace from luci.http.protocol.* to luci.http.*

Signed-off-by: Jo-Philipp Wich <redacted>
applications/luci-app-dnscrypt-proxy/Makefile
applications/luci-app-dnscrypt-proxy/luasrc/model/cbi/dnscrypt-proxy/overview_tab.lua
libs/luci-lib-httpclient/Makefile
libs/luci-lib-httpclient/luasrc/httpclient.lua
libs/luci-lib-httpprotoutils/Makefile [new file with mode: 0644]
libs/luci-lib-httpprotoutils/luasrc/http/conditionals.lua [moved from modules/luci-base/luasrc/http/protocol/conditionals.lua with 96% similarity]
libs/luci-lib-httpprotoutils/luasrc/http/conditionals.luadoc [moved from modules/luci-base/luasrc/http/protocol/conditionals.luadoc with 98% similarity]
libs/luci-lib-httpprotoutils/luasrc/http/date.lua [moved from modules/luci-base/luasrc/http/protocol/date.lua with 97% similarity]
libs/luci-lib-httpprotoutils/luasrc/http/date.luadoc [moved from modules/luci-base/luasrc/http/protocol/date.luadoc with 96% similarity]
libs/luci-lib-httpprotoutils/luasrc/http/mime.lua [moved from modules/luci-base/luasrc/http/protocol/mime.lua with 97% similarity]
libs/luci-lib-httpprotoutils/luasrc/http/mime.luadoc [moved from modules/luci-base/luasrc/http/protocol/mime.luadoc with 95% similarity]

index 4b632b8d04be9304c579a6b322acb2afc56690a7..d34fec87d7c8192780d5d381a261904ecd1e9133 100644 (file)
@@ -5,7 +5,7 @@
 include $(TOPDIR)/rules.mk
 
 LUCI_TITLE:=LuCI support for DNSCrypt-Proxy
-LUCI_DEPENDS:=+uclient-fetch +dnscrypt-proxy
+LUCI_DEPENDS:=+uclient-fetch +dnscrypt-proxy +luci-lib-httpprotoutils
 LUCI_PKGARCH:=all
 
 include ../../luci.mk
index 999c81dee782c1ebf066585998d063c07b8b8257..8f0e3224b49be626d4a438154533e167cc3ce12c 100644 (file)
@@ -4,7 +4,6 @@
 local fs        = require("nixio.fs")
 local uci       = require("luci.model.uci").cursor()
 local util      = require("luci.util")
-local date      = require("luci.http.protocol.date")
 local res_input = "/usr/share/dnscrypt-proxy/dnscrypt-resolvers.csv"
 local res_dir   = fs.dirname(res_input)
 local dump      = util.ubus("network.interface", "dump", {})
@@ -12,6 +11,11 @@ local plug_cnt  = tonumber(luci.sys.exec("env -i /usr/sbin/dnscrypt-proxy --vers
 local res_list  = {}
 local url       = "https://raw.githubusercontent.com/dyne/dnscrypt-proxy/master/dnscrypt-resolvers.csv"
 
+local _, date = pcall(require, "luci.http.date")
+if not date then
+       _, date = pcall(require, "luci.http.protocol.date")
+end
+
 if not fs.access(res_input) then
        if not fs.access("/lib/libustream-ssl.so") then
                m = SimpleForm("error", nil, translate("No default resolver list and no SSL support available.<br />")
index 1e7fd1bc856e9803ca09373da76e75430162b54b..b8bd428b2838ef9a8cede83dc227ff0538a362b2 100644 (file)
@@ -7,7 +7,7 @@
 include $(TOPDIR)/rules.mk
 
 LUCI_TITLE:=HTTP(S) client library
-LUCI_DEPENDS:=+luci-base +luci-lib-nixio
+LUCI_DEPENDS:=+luci-base +luci-lib-nixio +luci-lib-httpprotoutils
 
 include ../../luci.mk
 
index 04175b3647167560d176209d3d2713079fdb4fe7..3e8d7277d7ac76312c9566f226cc56f9dcc898bb 100644 (file)
@@ -8,7 +8,7 @@ local ltn12 = require "luci.ltn12"
 local util = require "luci.util"
 local table = require "table"
 local http = require "luci.http"
-local date = require "luci.http.protocol.date"
+local date = require "luci.http.date"
 
 local type, pairs, ipairs, tonumber = type, pairs, ipairs, tonumber
 local unpack = unpack
diff --git a/libs/luci-lib-httpprotoutils/Makefile b/libs/luci-lib-httpprotoutils/Makefile
new file mode 100644 (file)
index 0000000..851a362
--- /dev/null
@@ -0,0 +1,14 @@
+#
+# Copyright (C) 2018 The LuCI Team <luci@lists.subsignal.org>
+#
+# This is free software, licensed under the Apache License, Version 2.0 .
+#
+
+include $(TOPDIR)/rules.mk
+
+LUCI_TITLE:=HTTP protocol utility functions
+LUCI_DEPENDS:=+luci-base
+
+include ../../luci.mk
+
+# call BuildPackage - OpenWrt buildroot signature
similarity index 96%
rename from modules/luci-base/luasrc/http/protocol/conditionals.lua
rename to libs/luci-lib-httpprotoutils/luasrc/http/conditionals.lua
index d31a4e38a4f3eb2ed260d3fad5441f1c05271a43..86b4db29cdcde6c7685314fbcf1a9b83331a3ba2 100644 (file)
@@ -3,9 +3,9 @@
 
 -- This class provides basic ETag handling and implements most of the
 -- conditional HTTP/1.1 headers specified in RFC2616 Sct. 14.24 - 14.28 .
-module("luci.http.protocol.conditionals", package.seeall)
+module("luci.http.conditionals", package.seeall)
 
-local date = require("luci.http.protocol.date")
+local date = require("luci.http.date")
 
 
 function mk_etag( stat )
similarity index 98%
rename from modules/luci-base/luasrc/http/protocol/conditionals.luadoc
rename to libs/luci-lib-httpprotoutils/luasrc/http/conditionals.luadoc
index 9cfe02dd507f87b4cc2435cffceecf06ef70bde3..7ce0b5ebe34669bbfd239a6867f8527f9c048f62 100644 (file)
@@ -4,7 +4,7 @@ LuCI http protocol implementation - HTTP/1.1 bits.
 This class provides basic ETag handling and implements most of the
 conditional HTTP/1.1 headers specified in RFC2616 Sct. 14.24 - 14.28 .
 ]]
-module "luci.http.protocol.conditionals"
+module "luci.http.conditionals"
 
 ---[[
 Implement 14.19 / ETag.
similarity index 97%
rename from modules/luci-base/luasrc/http/protocol/date.lua
rename to libs/luci-lib-httpprotoutils/luasrc/http/date.lua
index e440219a9c8a443ecf48ded41bf70871e6509eac..72f1bdb5770c79934e22ff1b34efba89d6c51509 100644 (file)
@@ -2,7 +2,7 @@
 -- Licensed to the public under the Apache License 2.0.
 
 -- This class contains functions to parse, compare and format http dates.
-module("luci.http.protocol.date", package.seeall)
+module("luci.http.date", package.seeall)
 
 require("luci.sys.zoneinfo")
 
similarity index 96%
rename from modules/luci-base/luasrc/http/protocol/date.luadoc
rename to libs/luci-lib-httpprotoutils/luasrc/http/date.luadoc
index d6f1c8d658a645299cebd2e38d980f6cec35cd89..6028fb483711aeecc65d21fbce8264b5e89f12b8 100644 (file)
@@ -3,7 +3,7 @@ LuCI http protocol implementation - date helper class.
 
 This class contains functions to parse, compare and format http dates.
 ]]
-module "luci.http.protocol.date"
+module "luci.http.date"
 
 ---[[
 Return the time offset in seconds between the UTC and given time zone.
similarity index 97%
rename from modules/luci-base/luasrc/http/protocol/mime.lua
rename to libs/luci-lib-httpprotoutils/luasrc/http/mime.lua
index 2b99d8e74e2346e70081133eadde47971aaddcad..0bcff8a36b83e6e7780e747c8c1ba78694fd51fb 100644 (file)
@@ -3,7 +3,7 @@
 
 -- This class provides functions to guess mime types from file extensions and
 -- vice versa.
-module("luci.http.protocol.mime", package.seeall)
+module("luci.http.mime", package.seeall)
 
 require("luci.util")
 
similarity index 95%
rename from modules/luci-base/luasrc/http/protocol/mime.luadoc
rename to libs/luci-lib-httpprotoutils/luasrc/http/mime.luadoc
index 195b5fcc896fab8fbfc6b385a442826562b96cba..7751e2baf444cbdc429d31056fecfe18992b1f92 100644 (file)
@@ -4,7 +4,7 @@ LuCI http protocol implementation - mime helper class.
 This class provides functions to guess mime types from file extensions and
 vice versa.
 ]]
-module "luci.http.protocol.mime"
+module "luci.http.mime"
 
 ---[[
 MIME mapping table containg extension - mimetype relations.
git clone https://git.99rst.org/PROJECT