Codebase list lua-http / fresh-snapshots/main
New upstream snapshot. Debian Janitor 1 year, 4 months ago
15 changed file(s) with 80 addition(s) and 186 deletion(s). Raw diff Collapse all Expand all
+0
-109
.github/workflows/ci.yml less more
0 name: ci
1
2 on:
3 pull_request: {}
4 push:
5 branches: [ $default-branch ]
6
7 jobs:
8 luacheck:
9 runs-on: ubuntu-latest
10 steps:
11 - uses: actions/checkout@v2
12 with:
13 path: lua-http
14 - uses: leafo/gh-actions-lua@v8.0.0
15 - uses: leafo/gh-actions-luarocks@v4.0.0
16 - name: install-tooling
17 run: luarocks install luacheck
18 - name: luacheck
19 run: |
20 cd lua-http
21 luacheck .
22
23 test:
24 runs-on: ubuntu-latest
25 strategy:
26 matrix:
27 luaVersion:
28 - "5.1"
29 - "5.2"
30 - "5.3"
31 - "5.4"
32 - luajit-2.0.5
33 - luajit-2.1.0-beta3
34 luaCompileFlags: [""]
35 zlib: ["", "lzlib", "lua-zlib"]
36 remove_compat53: [false]
37
38 exclude:
39 # lzlib doesn't support Lua 5.4+
40 - luaVersion: "5.4"
41 zlib: "lzlib"
42 include:
43 - luaVersion: "5.3"
44 luaCompileFlags: LUA_CFLAGS="-DLUA_INT_TYPE=LUA_INT_INT"
45 - luaVersion: "5.3"
46 remove_compat53: true
47
48 steps:
49 - uses: actions/checkout@v2
50 with:
51 path: lua-http
52 - uses: leafo/gh-actions-lua@v8.0.0
53 with:
54 luaVersion: ${{ matrix.luaVersion }}
55 - uses: leafo/gh-actions-luarocks@v4.0.0
56 - name: install-tooling
57 run: |
58 luarocks install luacov-coveralls
59 luarocks install busted
60 - name: install-dependencies
61 run: |
62 cd lua-http
63 luarocks install --only-deps http-scm-0.rockspec
64
65 - name: install-lzlib
66 if: matrix.zlib == 'lzlib'
67 run: luarocks install lzlib
68 - name: install-lua-zlib
69 if: matrix.zlib == 'lua-zlib'
70 run: luarocks install lua-zlib
71
72 - name: remove-compat53
73 if: matrix.remove_compat53
74 run: luarocks remove compat53
75
76 - name: test
77 run: |
78 cd lua-http
79 busted -c -o utfTerminal
80
81 - name: coveralls
82 continue-on-error: true
83 env:
84 COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
85 run: |
86 cd lua-http
87 luacov-coveralls -v
88
89 typedlua:
90 runs-on: ubuntu-latest
91 steps:
92 - uses: actions/checkout@v2
93 with:
94 path: lua-http
95 - uses: leafo/gh-actions-lua@v8.0.0
96 with:
97 luaVersion: "5.3" # tlc doesn't work with 5.4+
98 - uses: leafo/gh-actions-luarocks@v4.0.0
99 - name: install-tooling
100 run: luarocks install https://raw.githubusercontent.com/andremm/typedlua/master/typedlua-scm-1.rockspec
101 - name: install-dependencies
102 run: |
103 cd lua-http
104 luarocks install --only-deps http-scm-0.rockspec
105 - name: typedlua
106 run: |
107 cd lua-http
108 tlc -o /dev/null spec/require-all.lua
+0
-3
.gitignore less more
0 /luacov.report.out
1 /luacov.stats.out
2 /*.rock
66 - Functionality for both client and server
77 - Cookie Management
88 - Websockets
9 - Compatible with Lua 5.1, 5.2, 5.3 and [LuaJIT](http://luajit.org/)
9 - Compatible with Lua 5.1, 5.2, 5.3, 5.4 and [LuaJIT](http://luajit.org/)
1010
1111
1212 ## Documentation
0 lua-http (0.4+git20210620.1.169c1a7-1) UNRELEASED; urgency=low
1
2 * New upstream snapshot.
3
4 -- Debian Janitor <janitor@jelmer.uk> Tue, 20 Dec 2022 02:56:00 -0000
5
06 lua-http (0.4-1) unstable; urgency=low
17
28 * New upstream version 0.4
6060
6161 ### `stream:get_body_until(pattern, plain, include_pattern, timeout)` <!-- --> {#stream:get_body_until}
6262
63 Reads in body data from the stream until the [lua pattern](http://www.lua.org/manual/5.3/manual.html#6.4.1) `pattern` is found and returns the data as a string. `plain` is a boolean that indicates that pattern matching facilities should be turned off so that function does a plain "find substring" operation, with no characters in pattern being considered magic. `include_patterns` specifies if the pattern itself should be included in the returned string. On error, returns `nil`, an error message and an error number.
63 Reads in body data from the stream until the [lua pattern](http://www.lua.org/manual/5.4/manual.html#6.4.1) `pattern` is found and returns the data as a string. `plain` is a boolean that indicates that pattern matching facilities should be turned off so that function does a plain "find substring" operation, with no characters in pattern being considered magic. `include_patterns` specifies if the pattern itself should be included in the returned string. On error, returns `nil`, an error message and an error number.
6464
6565
6666 ### `stream:save_body_to_file(file, timeout)` <!-- --> {#stream:save_body_to_file}
6767
68 Reads the body from the stream and saves it to the [lua file handle](http://www.lua.org/manual/5.3/manual.html#6.8) `file`. On error, returns `nil`, an error message and an error number.
68 Reads the body from the stream and saves it to the [lua file handle](http://www.lua.org/manual/5.4/manual.html#6.8) `file`. On error, returns `nil`, an error message and an error number.
6969
7070
7171 ### `stream:get_body_as_file(timeout)` <!-- --> {#stream:get_body_as_file}
7272
73 Reads the body from the stream into a temporary file and returns a [lua file handle](http://www.lua.org/manual/5.3/manual.html#6.8). On error, returns `nil`, an error message and an error number.
73 Reads the body from the stream into a temporary file and returns a [lua file handle](http://www.lua.org/manual/5.4/manual.html#6.8). On error, returns `nil`, an error message and an error number.
7474
7575
7676 ### `stream:unget(str)` <!-- --> {#stream:unget}
00 # Introduction
11
2 lua-http is an performant, capable HTTP and WebSocket library for Lua 5.1, 5.2, 5.3 and LuaJIT. Some of the features of the library include:
2 lua-http is an performant, capable HTTP and WebSocket library for Lua 5.1, 5.2, 5.3, 5.4 and LuaJIT. Some of the features of the library include:
33
44 - Support for HTTP versions 1, 1.1 and 2 as specified by [RFC 7230](https://tools.ietf.org/html/rfc7230) and [RFC 7540](https://tools.ietf.org/html/rfc7540)
55 - Provides both client and server APIs
5151
5252 A function used by the `store` to get the current time for expiries and such.
5353
54 Defaults to a function based on [`os.time`](https://www.lua.org/manual/5.3/manual.html#pdf-os.time).
54 Defaults to a function based on [`os.time`](https://www.lua.org/manual/5.4/manual.html#pdf-os.time).
5555
5656
5757 ### `store.max_cookie_length` <!-- --> {#http.cookie.store.max_cookie_length}
66
77 ### `proxies:update(getenv)` <!-- --> {#http.proxies:update}
88
9 `getenv` defaults to [`os.getenv`](http://www.lua.org/manual/5.3/manual.html#pdf-os.getenv)
9 `getenv` defaults to [`os.getenv`](http://www.lua.org/manual/5.4/manual.html#pdf-os.getenv)
1010
1111 Reads environmental variables that are used to control if requests go through a proxy.
1212
160160
161161 - If `body` is a string it will be sent as given.
162162 - If `body` is a function, it will be called repeatedly like an iterator. It should return chunks of the request body as a string or `nil` if done.
163 - If `body` is a lua file object, it will be [`:seek`'d](http://www.lua.org/manual/5.3/manual.html#pdf-file:seek) to the start, then sent as a body. Any errors encountered during file operations **will be thrown**.
163 - If `body` is a lua file object, it will be [`:seek`'d](http://www.lua.org/manual/5.4/manual.html#pdf-file:seek) to the start, then sent as a body. Any errors encountered during file operations **will be thrown**.
164164
165165
166166 ### `request:go(timeout)` <!-- --> {#http.request:timeout}
44
55 return {
66 name = "lua-http";
7 version = "0.4";
7 version = "scm";
88 }
+0
-58
http-0.4-0.rockspec less more
0 package = "http"
1 version = "0.4-0"
2
3 description = {
4 summary = "HTTP library for Lua";
5 homepage = "https://github.com/daurnimator/lua-http";
6 license = "MIT";
7 }
8
9 source = {
10 url = "https://github.com/daurnimator/lua-http/archive/v0.4.zip";
11 dir = "lua-http-0.4";
12 }
13
14 dependencies = {
15 "lua >= 5.1";
16 "compat53 >= 0.3"; -- Only if lua < 5.3
17 "bit32"; -- Only if lua == 5.1
18 "cqueues >= 20161214";
19 "luaossl >= 20161208";
20 "basexx >= 0.2.0";
21 "lpeg";
22 "lpeg_patterns >= 0.5";
23 "binaryheap >= 0.3";
24 "fifo";
25 -- "psl"; -- Optional
26 }
27
28 build = {
29 type = "builtin";
30 modules = {
31 ["http.bit"] = "http/bit.lua";
32 ["http.client"] = "http/client.lua";
33 ["http.connection_common"] = "http/connection_common.lua";
34 ["http.cookie"] = "http/cookie.lua";
35 ["http.h1_connection"] = "http/h1_connection.lua";
36 ["http.h1_reason_phrases"] = "http/h1_reason_phrases.lua";
37 ["http.h1_stream"] = "http/h1_stream.lua";
38 ["http.h2_connection"] = "http/h2_connection.lua";
39 ["http.h2_error"] = "http/h2_error.lua";
40 ["http.h2_stream"] = "http/h2_stream.lua";
41 ["http.headers"] = "http/headers.lua";
42 ["http.hpack"] = "http/hpack.lua";
43 ["http.hsts"] = "http/hsts.lua";
44 ["http.proxies"] = "http/proxies.lua";
45 ["http.request"] = "http/request.lua";
46 ["http.server"] = "http/server.lua";
47 ["http.socks"] = "http/socks.lua";
48 ["http.stream_common"] = "http/stream_common.lua";
49 ["http.tls"] = "http/tls.lua";
50 ["http.util"] = "http/util.lua";
51 ["http.version"] = "http/version.lua";
52 ["http.websocket"] = "http/websocket.lua";
53 ["http.zlib"] = "http/zlib.lua";
54 ["http.compat.prosody"] = "http/compat/prosody.lua";
55 ["http.compat.socket"] = "http/compat/socket.lua";
56 };
57 }
0 package = "http"
1 version = "scm-0"
2
3 description = {
4 summary = "HTTP library for Lua";
5 homepage = "https://github.com/daurnimator/lua-http";
6 license = "MIT";
7 }
8
9 source = {
10 url = "git+https://github.com/daurnimator/lua-http.git";
11 }
12
13 dependencies = {
14 "lua >= 5.1";
15 "compat53 >= 0.3"; -- Only if lua < 5.3
16 "bit32"; -- Only if lua == 5.1
17 "cqueues >= 20161214";
18 "luaossl >= 20161208";
19 "basexx >= 0.2.0";
20 "lpeg";
21 "lpeg_patterns >= 0.5";
22 "binaryheap >= 0.3";
23 "fifo";
24 -- "psl"; -- Optional
25 }
26
27 build = {
28 type = "builtin";
29 modules = {
30 ["http.bit"] = "http/bit.lua";
31 ["http.client"] = "http/client.lua";
32 ["http.connection_common"] = "http/connection_common.lua";
33 ["http.cookie"] = "http/cookie.lua";
34 ["http.h1_connection"] = "http/h1_connection.lua";
35 ["http.h1_reason_phrases"] = "http/h1_reason_phrases.lua";
36 ["http.h1_stream"] = "http/h1_stream.lua";
37 ["http.h2_connection"] = "http/h2_connection.lua";
38 ["http.h2_error"] = "http/h2_error.lua";
39 ["http.h2_stream"] = "http/h2_stream.lua";
40 ["http.headers"] = "http/headers.lua";
41 ["http.hpack"] = "http/hpack.lua";
42 ["http.hsts"] = "http/hsts.lua";
43 ["http.proxies"] = "http/proxies.lua";
44 ["http.request"] = "http/request.lua";
45 ["http.server"] = "http/server.lua";
46 ["http.socks"] = "http/socks.lua";
47 ["http.stream_common"] = "http/stream_common.lua";
48 ["http.tls"] = "http/tls.lua";
49 ["http.util"] = "http/util.lua";
50 ["http.version"] = "http/version.lua";
51 ["http.websocket"] = "http/websocket.lua";
52 ["http.zlib"] = "http/zlib.lua";
53 ["http.compat.prosody"] = "http/compat/prosody.lua";
54 ["http.compat.socket"] = "http/compat/socket.lua";
55 };
56 }
5151 s:close()
5252 end
5353 local function new_server_ctx()
54 local key = openssl_pkey.new()
54 local key = openssl_pkey.new({type="RSA", bits=2048})
5555 local crt = openssl_x509.new()
5656 crt:setPublicKey(key)
5757 crt:sign(key)
2525 it(":get works", function()
2626 local s = http_cookie.new_store()
2727 assert.same(nil, s:get("mysite.com", "/", "lang"))
28 local key, value, params = http_cookie.parse_setcookie("lang=en-US; Expires=Wed, 09 Jun 2021 10:18:14 GMT")
28 local key, value, params = http_cookie.parse_setcookie("lang=en-US; Expires=Wed, 09 Jun 2121 10:18:14 GMT")
2929 assert(s:store("mysite.com", "/", true, true, nil, key, value, params))
3030 assert.same("en-US", s:get("mysite.com", "/", "lang"))
3131 assert.same(nil, s:get("other.com", "/", "lang"))
6767 s.time = function() return 1234567890 end -- set time to something before the expiry
6868 -- in spec this is kept from previous example.
6969 assert(s:store("example.com", "/", true, true, nil, http_cookie.parse_setcookie("SID=31d4d96e407aad42; Path=/; Secure; HttpOnly")))
70 assert(s:store("example.com", "/", true, true, nil, http_cookie.parse_setcookie("lang=en-US; Expires=Wed, 09 Jun 2021 10:18:14 GMT")))
70 assert(s:store("example.com", "/", true, true, nil, http_cookie.parse_setcookie("lang=en-US; Expires=Wed, 09 Jun 2121 10:18:14 GMT")))
7171 assert.same("SID=31d4d96e407aad42; lang=en-US", s:lookup("example.com", "/", true, true))
7272 s.time = function() return 9234567890 end -- set time to something after the expiry
7373 assert.same("SID=31d4d96e407aad42", s:lookup("example.com", "/", true, true))
250250 end)
251251 it("cleans up", function()
252252 local s = http_cookie.new_store()
253 assert.truthy(s:store("example.com", "/", true, true, nil, http_cookie.parse_setcookie("foo=foo; Expires=Wed, 09 Jun 2021 10:18:14 GMT")))
253 assert.truthy(s:store("example.com", "/", true, true, nil, http_cookie.parse_setcookie("foo=foo; Expires=Wed, 09 Jun 2121 10:18:14 GMT")))
254254 assert.same("foo", s:get("example.com", "/", "foo"))
255255 s.time = function() return 9876543210 end -- set time to something after the expiry
256256 s:clean()
1616 local s, c = ca.assert(cs.pair())
1717 local cq = cqueues.new()
1818 cq:wrap(function()
19 local ctx = openssl_ctx.new("TLSv1", false)
19 local ctx = openssl_ctx.new("TLS", false)
2020 assert(c:starttls(ctx))
2121 local ssl = assert(s:checktls())
2222 local cipher = ssl:getCipherInfo()
2323 assert(tls.banned_ciphers[cipher.name])
2424 end)
2525 cq:wrap(function()
26 local ctx = openssl_ctx.new("TLSv1", true)
26 local ctx = openssl_ctx.new("TLS", true)
27 ctx:setOptions(openssl_ctx.OP_NO_TLSv1_3)
2728 ctx:setCipherList(banned_cipher_list)
2829 ctx:setEphemeralKey(openssl_pkey.new{ type = "EC", curve = "prime256v1" })
2930 local crt = openssl_x509.new()
30 local key = openssl_pkey.new()
31 local key = openssl_pkey.new({type="RSA", bits=2048})
3132 crt:setPublicKey(key)
3233 crt:sign(key)
3334 assert(ctx:setPrivateKey(key))