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:
Jo-Philipp Wich 2018-04-18 15:49:26 +02:00
parent eb4571c6dc
commit b4040aacb0
11 changed files with 29 additions and 11 deletions

View 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

View 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 />")

View 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

View 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

View 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

View 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 )

View 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.

View 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")

View 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.

View 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")

View 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.