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>
This commit is contained in:
parent
eb4571c6dc
commit
b4040aacb0
11 changed files with 29 additions and 11 deletions
|
@ -5,7 +5,7 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
LUCI_TITLE:=LuCI support for DNSCrypt-Proxy
|
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
|
LUCI_PKGARCH:=all
|
||||||
|
|
||||||
include ../../luci.mk
|
include ../../luci.mk
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
local fs = require("nixio.fs")
|
local fs = require("nixio.fs")
|
||||||
local uci = require("luci.model.uci").cursor()
|
local uci = require("luci.model.uci").cursor()
|
||||||
local util = require("luci.util")
|
local util = require("luci.util")
|
||||||
local date = require("luci.http.protocol.date")
|
|
||||||
local res_input = "/usr/share/dnscrypt-proxy/dnscrypt-resolvers.csv"
|
local res_input = "/usr/share/dnscrypt-proxy/dnscrypt-resolvers.csv"
|
||||||
local res_dir = fs.dirname(res_input)
|
local res_dir = fs.dirname(res_input)
|
||||||
local dump = util.ubus("network.interface", "dump", {})
|
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 res_list = {}
|
||||||
local url = "https://raw.githubusercontent.com/dyne/dnscrypt-proxy/master/dnscrypt-resolvers.csv"
|
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(res_input) then
|
||||||
if not fs.access("/lib/libustream-ssl.so") 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 />")
|
m = SimpleForm("error", nil, translate("No default resolver list and no SSL support available.<br />")
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
LUCI_TITLE:=HTTP(S) client library
|
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
|
include ../../luci.mk
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ local ltn12 = require "luci.ltn12"
|
||||||
local util = require "luci.util"
|
local util = require "luci.util"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local http = require "luci.http"
|
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 type, pairs, ipairs, tonumber = type, pairs, ipairs, tonumber
|
||||||
local unpack = unpack
|
local unpack = unpack
|
||||||
|
|
14
libs/luci-lib-httpprotoutils/Makefile
Normal file
14
libs/luci-lib-httpprotoutils/Makefile
Normal file
|
@ -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
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
-- This class provides basic ETag handling and implements most of the
|
-- This class provides basic ETag handling and implements most of the
|
||||||
-- conditional HTTP/1.1 headers specified in RFC2616 Sct. 14.24 - 14.28 .
|
-- 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 )
|
function mk_etag( stat )
|
|
@ -4,7 +4,7 @@ LuCI http protocol implementation - HTTP/1.1 bits.
|
||||||
This class provides basic ETag handling and implements most of the
|
This class provides basic ETag handling and implements most of the
|
||||||
conditional HTTP/1.1 headers specified in RFC2616 Sct. 14.24 - 14.28 .
|
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.
|
Implement 14.19 / ETag.
|
|
@ -2,7 +2,7 @@
|
||||||
-- Licensed to the public under the Apache License 2.0.
|
-- Licensed to the public under the Apache License 2.0.
|
||||||
|
|
||||||
-- This class contains functions to parse, compare and format http dates.
|
-- 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")
|
require("luci.sys.zoneinfo")
|
||||||
|
|
|
@ -3,7 +3,7 @@ LuCI http protocol implementation - date helper class.
|
||||||
|
|
||||||
This class contains functions to parse, compare and format http dates.
|
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.
|
Return the time offset in seconds between the UTC and given time zone.
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
-- This class provides functions to guess mime types from file extensions and
|
-- This class provides functions to guess mime types from file extensions and
|
||||||
-- vice versa.
|
-- vice versa.
|
||||||
module("luci.http.protocol.mime", package.seeall)
|
module("luci.http.mime", package.seeall)
|
||||||
|
|
||||||
require("luci.util")
|
require("luci.util")
|
||||||
|
|
|
@ -4,7 +4,7 @@ LuCI http protocol implementation - mime helper class.
|
||||||
This class provides functions to guess mime types from file extensions and
|
This class provides functions to guess mime types from file extensions and
|
||||||
vice versa.
|
vice versa.
|
||||||
]]
|
]]
|
||||||
module "luci.http.protocol.mime"
|
module "luci.http.mime"
|
||||||
|
|
||||||
---[[
|
---[[
|
||||||
MIME mapping table containg extension - mimetype relations.
|
MIME mapping table containg extension - mimetype relations.
|
Loading…
Reference in a new issue