Import upstream version 0.4+git20210206.1.54606a9
Debian Janitor
3 years ago
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 |
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 | } |