New upstream snapshot.
Debian Janitor
1 year, 4 months ago
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 |
6 | 6 | - Functionality for both client and server |
7 | 7 | - Cookie Management |
8 | 8 | - 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/) | |
10 | 10 | |
11 | 11 | |
12 | 12 | ## 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 | ||
0 | 6 | lua-http (0.4-1) unstable; urgency=low |
1 | 7 | |
2 | 8 | * New upstream version 0.4 |
60 | 60 | |
61 | 61 | ### `stream:get_body_until(pattern, plain, include_pattern, timeout)` <!-- --> {#stream:get_body_until} |
62 | 62 | |
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. | |
64 | 64 | |
65 | 65 | |
66 | 66 | ### `stream:save_body_to_file(file, timeout)` <!-- --> {#stream:save_body_to_file} |
67 | 67 | |
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. | |
69 | 69 | |
70 | 70 | |
71 | 71 | ### `stream:get_body_as_file(timeout)` <!-- --> {#stream:get_body_as_file} |
72 | 72 | |
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. | |
74 | 74 | |
75 | 75 | |
76 | 76 | ### `stream:unget(str)` <!-- --> {#stream:unget} |
0 | 0 | # Introduction |
1 | 1 | |
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: | |
3 | 3 | |
4 | 4 | - 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) |
5 | 5 | - Provides both client and server APIs |
51 | 51 | |
52 | 52 | A function used by the `store` to get the current time for expiries and such. |
53 | 53 | |
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). | |
55 | 55 | |
56 | 56 | |
57 | 57 | ### `store.max_cookie_length` <!-- --> {#http.cookie.store.max_cookie_length} |
6 | 6 | |
7 | 7 | ### `proxies:update(getenv)` <!-- --> {#http.proxies:update} |
8 | 8 | |
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) | |
10 | 10 | |
11 | 11 | Reads environmental variables that are used to control if requests go through a proxy. |
12 | 12 |
160 | 160 | |
161 | 161 | - If `body` is a string it will be sent as given. |
162 | 162 | - 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**. | |
164 | 164 | |
165 | 165 | |
166 | 166 | ### `request:go(timeout)` <!-- --> {#http.request:timeout} |
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 | } |
51 | 51 | s:close() |
52 | 52 | end |
53 | 53 | local function new_server_ctx() |
54 | local key = openssl_pkey.new() | |
54 | local key = openssl_pkey.new({type="RSA", bits=2048}) | |
55 | 55 | local crt = openssl_x509.new() |
56 | 56 | crt:setPublicKey(key) |
57 | 57 | crt:sign(key) |
25 | 25 | it(":get works", function() |
26 | 26 | local s = http_cookie.new_store() |
27 | 27 | 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") | |
29 | 29 | assert(s:store("mysite.com", "/", true, true, nil, key, value, params)) |
30 | 30 | assert.same("en-US", s:get("mysite.com", "/", "lang")) |
31 | 31 | assert.same(nil, s:get("other.com", "/", "lang")) |
67 | 67 | s.time = function() return 1234567890 end -- set time to something before the expiry |
68 | 68 | -- in spec this is kept from previous example. |
69 | 69 | 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"))) | |
71 | 71 | assert.same("SID=31d4d96e407aad42; lang=en-US", s:lookup("example.com", "/", true, true)) |
72 | 72 | s.time = function() return 9234567890 end -- set time to something after the expiry |
73 | 73 | assert.same("SID=31d4d96e407aad42", s:lookup("example.com", "/", true, true)) |
250 | 250 | end) |
251 | 251 | it("cleans up", function() |
252 | 252 | 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"))) | |
254 | 254 | assert.same("foo", s:get("example.com", "/", "foo")) |
255 | 255 | s.time = function() return 9876543210 end -- set time to something after the expiry |
256 | 256 | s:clean() |
16 | 16 | local s, c = ca.assert(cs.pair()) |
17 | 17 | local cq = cqueues.new() |
18 | 18 | cq:wrap(function() |
19 | local ctx = openssl_ctx.new("TLSv1", false) | |
19 | local ctx = openssl_ctx.new("TLS", false) | |
20 | 20 | assert(c:starttls(ctx)) |
21 | 21 | local ssl = assert(s:checktls()) |
22 | 22 | local cipher = ssl:getCipherInfo() |
23 | 23 | assert(tls.banned_ciphers[cipher.name]) |
24 | 24 | end) |
25 | 25 | 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) | |
27 | 28 | ctx:setCipherList(banned_cipher_list) |
28 | 29 | ctx:setEphemeralKey(openssl_pkey.new{ type = "EC", curve = "prime256v1" }) |
29 | 30 | local crt = openssl_x509.new() |
30 | local key = openssl_pkey.new() | |
31 | local key = openssl_pkey.new({type="RSA", bits=2048}) | |
31 | 32 | crt:setPublicKey(key) |
32 | 33 | crt:sign(key) |
33 | 34 | assert(ctx:setPrivateKey(key)) |