From ebed8a9d80aa476cbd5fc9c8c24ae8eb429177f7 Mon Sep 17 00:00:00 2001 From: Tomas Krizek Date: Apr 17 2019 10:47:16 +0000 Subject: initial package --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2d0d041 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/lua-http-0.3.tar.gz diff --git a/0001-rst_closed.patch b/0001-rst_closed.patch new file mode 100644 index 0000000..7a56d2b --- /dev/null +++ b/0001-rst_closed.patch @@ -0,0 +1,21 @@ +commit 97d2e97fe1dd9d4209d6c502f9a84ce2b7be1701 +Author: Petr Špaček +Date: Fri Apr 12 13:34:49 2019 +0200 + + http/h2_stream: ignore delayed RST_STREAM frames + + Fixes: #145 + +diff --git a/http/h2_stream.lua b/http/h2_stream.lua +index abd3899..689c8ec 100644 +--- a/http/h2_stream.lua ++++ b/http/h2_stream.lua +@@ -690,6 +690,8 @@ frame_handlers[frame_types.RST_STREAM] = function(stream, flags, payload, deadli + end + if stream.state == "idle" then + return nil, h2_errors.PROTOCOL_ERROR:new_traceback("'RST_STREAM' frames MUST NOT be sent for a stream in the 'idle' state"), ce.EILSEQ ++ elseif stream.state == "closed" then -- probably a delayed RST_STREAM, ignore ++ return true + end + + local err_code = sunpack(">I4", payload) diff --git a/0002-throw_kill_connection.patch b/0002-throw_kill_connection.patch new file mode 100644 index 0000000..212aedc --- /dev/null +++ b/0002-throw_kill_connection.patch @@ -0,0 +1,34 @@ +commit d2543217f5e0f38040444b164650808f2c366d54 +Author: Petr Špaček +Date: Fri Apr 12 16:44:52 2019 +0200 + + http/server: close connection on unhandled internal errors + + Fixes: #146 + + I'm not sure if implementation is correct, or if it best way to handle + it. In any case it fixes client-visible problem where lua-http server + keep connection open even after internal error (like #145). + +diff --git a/http/server.lua b/http/server.lua +index 7f5bfd0..1dcf2be 100644 +--- a/http/server.lua ++++ b/http/server.lua +@@ -152,7 +152,16 @@ local function handle_socket(self, socket) + while true do + local timeout = deadline and deadline-monotime() or self.intra_stream_timeout + local stream +- stream, err, errno = conn:get_next_incoming_stream(timeout) ++ local stream_or_err ++ local finished ++ finished, stream_or_err, err, errno = xpcall(conn.get_next_incoming_stream, debug.traceback, conn, timeout) ++ if not finished then -- uncaught internal error, terminate connection ++ err = stream_or_err ++ errno = ce.EFAULT ++ stream = nil ++ else ++ stream = stream_or_err ++ end + if stream == nil then + if (err ~= nil -- client closed connection + and errno ~= ce.ECONNRESET diff --git a/lua-http.spec b/lua-http.spec new file mode 100644 index 0000000..022386b --- /dev/null +++ b/lua-http.spec @@ -0,0 +1,108 @@ +%{!?luaver: %global luaver %(lua -e "print(string.sub(_VERSION, 5))" || echo 0)} +%global luapkgdir %{_datadir}/lua/%{luaver} + +%global luacompatver 5.1 +%global luacompatpkgdir %{_datadir}/lua/%{luacompatver} + +%global luapkgname http + +Name: lua-%{luapkgname} +Version: 0.3 +Release: 1%{?dist} +Summary: HTTP library for Lua + +License: MIT +URL: https://github.com/daurnimator/lua-http +Source0: https://github.com/daurnimator/lua-http/archive/v%{version}/%{name}-%{version}.tar.gz +BuildArch: noarch + +Patch1: 0001-rst_closed.patch +Patch2: 0002-throw_kill_connection.patch + +BuildRequires: lua +BuildRequires: pandoc + +Requires: lua-basexx >= 0.2.0 +Requires: lua-binaryheap >= 0.3 +Requires: lua-fifo +Requires: lua-luaossl >= 20161208 +Requires: lua-lpeg +Requires: lua-lpeg-patterns >= 0.5 +Requires: lua-cqueues >= 20171014 + +%description +lua-http is an efficient, capable HTTP and WebSocket library for Lua. + +%if 0%{?fedora} || 0%{?rhel} > 7 +%package -n lua%{luacompatver}-%{luapkgname} +Summary: HTTP library for Lua +Requires: lua%{luacompatver}-basexx >= 0.2.0 +Requires: lua%{luacompatver}-binaryheap >= 0.3 +Requires: lua%{luacompatver}-bitop +Requires: lua%{luacompatver}-compat53 >= 0.3 +Requires: lua%{luacompatver}-fifo +Requires: lua%{luacompatver}-luaossl >= 20161208 +Requires: lua%{luacompatver}-lpeg +Requires: lua%{luacompatver}-lpeg-patterns >= 0.5 +Requires: lua%{luacompatver}-cqueues >= 20171014 + +%description -n lua%{luacompatver}-%{luapkgname} +lua-http is an efficient, capable HTTP and WebSocket library for Lua %{luacompatver}. +%endif + +%package doc +Summary: Documentation for HTTP library for Lua +Requires: %{name} = %{version} +%if 0%{?fedora} || 0%{?rhel} > 7 +Requires: lua{%luacompatver}-%{luapkgname} = %{version} +%endif + +%description doc +Documentation for the HTTP library for Lua. + +%prep +%setup -q -n %{name}-%{version} +%patch1 -p1 +%patch2 -p1 + +%build +pushd doc +%make_build lua-http.html lua-http.3 +popd + +%install +install -d -m 0755 "%{buildroot}%{_pkgdocdir}" +install -p -m 0644 doc/lua-http.html "%{buildroot}%{_pkgdocdir}/index.html" +install -D -p -m 0644 doc/lua-http.3 "%{buildroot}%{_mandir}/man3/lua-http.3" + +install -d -m 0755 %{buildroot}%{luapkgdir}/%{luapkgname} +install -p -m 0644 %{luapkgname}/*.lua -t "%{buildroot}%{luapkgdir}/%{luapkgname}/" +install -d -m 0755 %{buildroot}%{luapkgdir}/%{luapkgname}/compat +install -p -m 0644 %{luapkgname}/compat/*.lua -t "%{buildroot}%{luapkgdir}/%{luapkgname}/compat/" + +%if 0%{?fedora} || 0%{?rhel} > 7 +install -d -m 0755 %{buildroot}%{luacompatpkgdir}/%{luapkgname} +install -p -m 0644 %{luapkgname}/*.lua -t "%{buildroot}%{luacompatpkgdir}/%{luapkgname}/" +install -d -m 0755 %{buildroot}%{luacompatpkgdir}/%{luapkgname}/compat +install -p -m 0644 %{luapkgname}/compat/*.lua -t "%{buildroot}%{luacompatpkgdir}/%{luapkgname}/compat/" +%endif + +%files +%{_mandir}/man3/lua-http.3* +%license LICENSE.md +%{luapkgdir}/%{luapkgname} + +%if 0%{?fedora} || 0%{?rhel} > 7 +%files -n lua%{luacompatver}-%{luapkgname} +%{_mandir}/man3/lua-http.3* +%license LICENSE.md +%{luacompatpkgdir}/%{luapkgname} +%endif + +%files doc +%{_pkgdocdir} +%doc %{_pkgdocdir}/index.html + +%changelog +* Tue Apr 09 2019 Tomas Krizek - 0.3-1 +- Initial package for Fedora 28+ and EPEL 7+ diff --git a/sources b/sources new file mode 100644 index 0000000..f84fc49 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (lua-http-0.3.tar.gz) = 5728848849e8d3e99328abdc6aff3034a708f0e5884e8718a9266900a561a37850e2bf911e9cbd0d4d538799e1fd8bb4fd66008f4787011f5802b259d51f8281