Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ before_install:
- export PATH=$PATH:~/hererocks/bin
- eval $(luarocks path --bin)
- luarocks install luacheck
- luarocks install https://raw.githubusercontent.com/andremm/typedlua/master/typedlua-scm-1.rockspec
- luarocks install luacov-coveralls
- luarocks install busted

Expand All @@ -46,6 +47,7 @@ install:

script:
- luacheck .
- tlc -o /dev/null spec/require-all.lua
- busted -c

after_success:
Expand Down
3 changes: 3 additions & 0 deletions http/bit.tld
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
band: (integer, integer) -> (integer)
bor: (integer, integer) -> (integer)
bxor: (integer, integer) -> (integer)
19 changes: 19 additions & 0 deletions http/connection_common.tld
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
interface connection
-- implements cqueues polling interface
const pollfd: (self) -> (nil)|(integer) -- TODO: cqueues condition
const events: (self) -> (nil)|(string|integer)
const timeout: (self) -> (nil)|(number)

const checktls: (self) -> (nil)|(any) -- TODO: luaossl SSL object
const localname: (self) -> (integer, string, integer?)|(nil)|(nil, string, number)
const peername: (self) -> (integer, string, integer?)|(nil)|(nil, string, number)
const onidle: (self, (connection)->()) -> ((connection)->())
const connect: (self) -> (true)|(nil)|(nil, string, number)
const flush: (self, number) -> (true)|(nil, string, number)
const close: (self) -> (true)

-- Not in connection_common.lua
const version: integer
const unget: (self, string) -> (true)
const shutdown: (self) -> (true)
end
28 changes: 28 additions & 0 deletions http/cookie.tld
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require "http.headers"

bake: (string, string, number?, string?, string?, true?, true?, string?) -> (string)

parse_cookie: (string) -> ({string:string})
parse_cookies: (headers) -> ({{string:string}})
parse_setcookie: (string) -> (string, string, {string:string})

interface cookie_store
psl: any|false -- TODO: use psl type
time: () -> (number)
max_cookie_length: number
max_cookies: number
max_cookies_per_domain: number

const store: (self, string, string, boolean, boolean, string?, string, string, {string:string}) -> (boolean)
const store_from_request: (self, headers, headers, string, string?) -> (boolean)
const get: (self, string, string, string) -> (string)
const remove: (self, string, string?, string?) -> ()
const lookup: (self, string, string, boolean?, boolean?, boolean?, string?, boolean?, integer?) -> ()
const lookup_for_request: (self, headers, string, string?, boolean?, integer?) -> ()
const clean_due: (self) -> (number)
const clean: (self) -> (boolean)
const load_from_file: (self, file) -> (true) | (nil, string, integer)
const save_to_file: (self, file) -> (true) | (nil, string, integer)
end

new_store: () -> (cookie_store)
1 change: 1 addition & 0 deletions http/h1_reason_phrases.tld
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
reason_phrases: {string:string}
15 changes: 15 additions & 0 deletions http/h2_error.tld
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
interface h2_error
const new: (self, {
"name": string?,
"code": integer?,
"description": string?,
"message": string?,
"traceback": string?,
"stream_error": boolean?
}) -> (h2_error)
const new_traceback: (self, string, boolean, integer?) -> (h2_error)
const error: (self, string, boolean, integer?) -> (void)
end

errors: {any:h2_error}
is: (any) -> (boolean)
26 changes: 13 additions & 13 deletions http/headers.tld
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
interface headers
const clone : (self) -> headers
const append : (self, string, string, nil|boolean) -> ()
const each : (self) -> ((self) -> (string, string, boolean))
const has : (self, string) -> (boolean)
const delete : (self, string) -> (boolean)
const geti : (self, integer) -> (string, string, boolean)
const get_as_sequence : (self, string) -> ({"n": integer, integer:string})
const get : (self, string) -> (string*)
const get_comma_separated : (self, string) -> (string|nil)
const modifyi : (self, integer, string, boolean?) -> ()
const upsert : (self, string, string, boolean?) -> ()
const sort : (self) -> ()
const dump : (self, nil|file, nil|string) -> ()
const clone: (self) -> (headers)
const append: (self, string, string, boolean?) -> ()
const each: (self) -> ((self) -> (string, string, boolean))
const has: (self, string) -> (boolean)
const delete: (self, string) -> (boolean)
const geti: (self, integer) -> (string, string, boolean)
const get_as_sequence: (self, string) -> ({"n": integer, integer:string})
const get: (self, string) -> (string*)
const get_comma_separated: (self, string) -> (string|nil)
const modifyi: (self, integer, string, boolean?) -> ()
const upsert: (self, string, string, boolean?) -> ()
const sort: (self) -> ()
const dump: (self, file?, string?) -> ()
end

new : () -> (headers)
13 changes: 13 additions & 0 deletions http/hsts.tld
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
interface hsts_store
time: () -> (number)
max_items: number

clone: (self) -> (hsts_store)
store: (self, string, {string:string}) -> (boolean)
remove: (self, string) -> (boolean)
check: (self, hsts_store) -> (boolean)
const clean_due: (self) -> (number)
const clean: (self) -> (boolean)
end

new_store: () -> (hsts_store)
6 changes: 6 additions & 0 deletions http/proxies.tld
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
interface proxies
const update: (self, (string)->(string?))->(self)
const choose: (self, string, string)->(string?)
end

new: proxies
26 changes: 26 additions & 0 deletions http/request.tld
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require "http.cookie"
require "http.hsts"
require "http.proxies"
require "http.stream_common"

interface request
hsts: hsts_store|false
proxies: proxies|false
cookie_store: cookie_store|false
is_top_level: boolean
site_for_cookies: string?
expect_100_timeout: integer
follow_redirects: boolean
max_redirects: integer
post301: boolean
post302: boolean
headers: headers
const clone: (self) -> (request)
const to_uri: (self, boolean?) -> (string)
const handle_redirect: (self, headers) -> (request)|(nil, string, integer)
const set_body: (self, string|file|()->(string?)) -> ()
const go: (self, number) -> (headers, stream)|(nil, string, integer)
end

new_from_uri: (string, headers?) -> (request)
new_connect: (string, string) -> (request)
22 changes: 22 additions & 0 deletions http/stream_common.tld
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require "http.connection_common"

interface stream
const checktls: (self) -> (nil)|(any)
const localname: (self) -> (integer, string, integer?)|(nil)|(nil, string, number)
const peername: (self) -> (integer, string, integer?)|(nil)|(nil, string, number)
const write_continue: (self, number?) -> (true)|(nil, string, number)
const each_chunk: (self) -> ()
const get_body_as_string: (self, number?) -> (string)|(nil, string, number)
const get_body_chars: (self, integer, number?) -> (string)|(nil, string, number)
const get_body_until: (self, string, boolean, boolean, number?) -> (string)|(nil, string, number)
const save_body_to_file: (self, file, number?) -> (true)|(nil, string, number)
const get_body_as_file: (self, number?) -> (file)|(nil, string, number)
const write_body_from_string: (self, string, number?) -> (true)|(nil, string, number)
const write_body_from_file: (self, {"file":file, "count": integer?}|file, number?) -> (true)|(nil, string, number)
-- Not in stream_common.lua
const connection: connection
const write_headers: (self, headers, boolean, number?) -> (true)|(nil, string, number)
const write_chunk: (self, string, boolean, number?) -> (true)|(nil, string, number)
const unget: (self, string) -> (true)
const shutdown: (self) -> (true)
end
9 changes: 9 additions & 0 deletions http/tls.tld
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
has_alpn: boolean
has_hostname_validation: boolean
modern_cipher_list: string
intermediate_cipher_list: string
old_cipher_list: string
banned_ciphers: {string: true}
-- TODO: luaossl SSL context type
new_client_context: any
new_server_context: any
15 changes: 15 additions & 0 deletions http/util.tld
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
encodeURI: (string) -> (string)
encodeURIComponent: (string) -> (string)
decodeURI: (string) -> (string)
decodeURIComponent: (string) -> (string)
query_args: (string) -> ((any) -> (string, string), any, any)
dict_to_query: ({string:string}) -> (string)
resolve_relative_path: (orig_path, relative_path) -> (string)
is_safe_method: (method) -> (boolean)
is_ip: (string) -> (boolean)
scheme_to_port: {string:integer}
split_authority: (string, string) -> (string, integer)|(nil, string)
to_authority: (string, integer, string|nil) -> (string)
imf_date: (time) -> (string)
maybe_quote: (string) -> (string)
yieldable_pcall: ((any*) -> (any*), any*) -> (boolean, any*)
2 changes: 2 additions & 0 deletions http/version.tld
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: string
version: string
2 changes: 2 additions & 0 deletions http/zlib.tld
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
inflate: () -> ((string, boolean) -> (string))
deflate: () -> ((string, boolean) -> (string))
27 changes: 27 additions & 0 deletions spec/require-all.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-- This file is used for linting .tld files with typedlua

require "http.bit"
require "http.client"
require "http.connection_common"
require "http.cookie"
require "http.h1_connection"
require "http.h1_reason_phrases"
require "http.h1_stream"
require "http.h2_connection"
require "http.h2_error"
require "http.h2_stream"
require "http.headers"
require "http.hpack"
require "http.hsts"
require "http.proxies"
require "http.request"
require "http.server"
require "http.socks"
require "http.stream_common"
require "http.tls"
require "http.util"
require "http.version"
require "http.websocket"
require "http.zlib"
require "http.compat.prosody"
require "http.compat.socket"