diff options
author | Jo-Philipp Wich <jo@mein.io> | 2018-04-18 15:49:26 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2018-04-18 16:21:27 +0200 |
commit | b4040aacb04ce38b7eae315d37b2a61a38aea4b1 (patch) | |
tree | e8b38cd68d04f5a2bcac5d55294cd591558e349a | |
parent | eb4571c6dc7e9f99133de1d7df23024ba6d31d9e (diff) |
libs: move http.protocol.{date,mime,conditionals} to luci-lib-httpprotoutils
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 <jo@mein.io>
11 files changed, 29 insertions, 11 deletions
diff --git a/applications/luci-app-dnscrypt-proxy/Makefile b/applications/luci-app-dnscrypt-proxy/Makefile index 4b632b8d0..d34fec87d 100644 --- a/applications/luci-app-dnscrypt-proxy/Makefile +++ b/applications/luci-app-dnscrypt-proxy/Makefile @@ -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 diff --git a/applications/luci-app-dnscrypt-proxy/luasrc/model/cbi/dnscrypt-proxy/overview_tab.lua b/applications/luci-app-dnscrypt-proxy/luasrc/model/cbi/dnscrypt-proxy/overview_tab.lua index 999c81dee..8f0e3224b 100644 --- a/applications/luci-app-dnscrypt-proxy/luasrc/model/cbi/dnscrypt-proxy/overview_tab.lua +++ b/applications/luci-app-dnscrypt-proxy/luasrc/model/cbi/dnscrypt-proxy/overview_tab.lua @@ -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 />") diff --git a/libs/luci-lib-httpclient/Makefile b/libs/luci-lib-httpclient/Makefile index 1e7fd1bc8..b8bd428b2 100644 --- a/libs/luci-lib-httpclient/Makefile +++ b/libs/luci-lib-httpclient/Makefile @@ -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 diff --git a/libs/luci-lib-httpclient/luasrc/httpclient.lua b/libs/luci-lib-httpclient/luasrc/httpclient.lua index 04175b364..3e8d7277d 100644 --- a/libs/luci-lib-httpclient/luasrc/httpclient.lua +++ b/libs/luci-lib-httpclient/luasrc/httpclient.lua @@ -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 index 000000000..851a362eb --- /dev/null +++ b/libs/luci-lib-httpprotoutils/Makefile @@ -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 diff --git a/modules/luci-base/luasrc/http/protocol/conditionals.lua b/libs/luci-lib-httpprotoutils/luasrc/http/conditionals.lua index d31a4e38a..86b4db29c 100644 --- a/modules/luci-base/luasrc/http/protocol/conditionals.lua +++ b/libs/luci-lib-httpprotoutils/luasrc/http/conditionals.lua @@ -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 ) diff --git a/modules/luci-base/luasrc/http/protocol/conditionals.luadoc b/libs/luci-lib-httpprotoutils/luasrc/http/conditionals.luadoc index 9cfe02dd5..7ce0b5ebe 100644 --- a/modules/luci-base/luasrc/http/protocol/conditionals.luadoc +++ b/libs/luci-lib-httpprotoutils/luasrc/http/conditionals.luadoc @@ -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. diff --git a/modules/luci-base/luasrc/http/protocol/date.lua b/libs/luci-lib-httpprotoutils/luasrc/http/date.lua index e440219a9..72f1bdb57 100644 --- a/modules/luci-base/luasrc/http/protocol/date.lua +++ b/libs/luci-lib-httpprotoutils/luasrc/http/date.lua @@ -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") diff --git a/modules/luci-base/luasrc/http/protocol/date.luadoc b/libs/luci-lib-httpprotoutils/luasrc/http/date.luadoc index d6f1c8d65..6028fb483 100644 --- a/modules/luci-base/luasrc/http/protocol/date.luadoc +++ b/libs/luci-lib-httpprotoutils/luasrc/http/date.luadoc @@ -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. diff --git a/modules/luci-base/luasrc/http/protocol/mime.lua b/libs/luci-lib-httpprotoutils/luasrc/http/mime.lua index 2b99d8e74..0bcff8a36 100644 --- a/modules/luci-base/luasrc/http/protocol/mime.lua +++ b/libs/luci-lib-httpprotoutils/luasrc/http/mime.lua @@ -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") diff --git a/modules/luci-base/luasrc/http/protocol/mime.luadoc b/libs/luci-lib-httpprotoutils/luasrc/http/mime.luadoc index 195b5fcc8..7751e2baf 100644 --- a/modules/luci-base/luasrc/http/protocol/mime.luadoc +++ b/libs/luci-lib-httpprotoutils/luasrc/http/mime.luadoc @@ -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. |