mirror of
https://github.com/bjc/prosody.git
synced 2025-04-04 05:37:39 +03:00
net.http: Add teal description files
This commit is contained in:
parent
185b679953
commit
d459ec2f5d
6 changed files with 190 additions and 0 deletions
88
teal-src/net/http.d.tl
Normal file
88
teal-src/net/http.d.tl
Normal file
|
@ -0,0 +1,88 @@
|
|||
local record Promise
|
||||
-- util.promise
|
||||
end
|
||||
|
||||
local record sslctx -- from LuaSec
|
||||
end
|
||||
|
||||
local record lib
|
||||
|
||||
enum http_method
|
||||
"GET"
|
||||
"HEAD"
|
||||
"POST"
|
||||
"PUT"
|
||||
"OPTIONS"
|
||||
"DELETE"
|
||||
-- etc?
|
||||
end
|
||||
|
||||
record http_client_options
|
||||
sslctx : sslctx
|
||||
end
|
||||
|
||||
record http_options
|
||||
id : string
|
||||
onlystatus : boolean
|
||||
body : string
|
||||
method : http_method
|
||||
headers : { string : string }
|
||||
insecure : boolean
|
||||
suppress_errors : boolean
|
||||
streaming_handler : function
|
||||
suppress_url : boolean
|
||||
sslctx : sslctx
|
||||
end
|
||||
|
||||
record http_request
|
||||
host : string
|
||||
port : string
|
||||
enum scheme
|
||||
"http"
|
||||
"https"
|
||||
end
|
||||
scheme : scheme
|
||||
url : string
|
||||
userinfo : string
|
||||
path : string
|
||||
|
||||
method : http_method
|
||||
headers : { string : string }
|
||||
|
||||
insecure : boolean
|
||||
suppress_errors : boolean
|
||||
streaming_handler : function
|
||||
http : http_client
|
||||
time : integer
|
||||
id : string
|
||||
callback : http_callback
|
||||
end
|
||||
|
||||
record http_response
|
||||
end
|
||||
|
||||
type http_callback = function (string, number, http_response, http_request)
|
||||
|
||||
record http_client
|
||||
options : http_client_options
|
||||
request : function (http_client, string, http_options, http_callback)
|
||||
end
|
||||
|
||||
request : function (string, http_options, http_callback) : Promise, string
|
||||
default : http_client
|
||||
new : function (http_client_options) : http_client
|
||||
events : table
|
||||
-- COMPAT
|
||||
urlencode : function (string) : string
|
||||
urldecode : function (string) : string
|
||||
formencode : function ({ string : string }) : string
|
||||
formdecode : function (string) : { string : string }
|
||||
destroy_request : function (http_request)
|
||||
|
||||
enum available_features
|
||||
"sni"
|
||||
end
|
||||
features : { available_features : boolean }
|
||||
end
|
||||
|
||||
return lib
|
2
teal-src/net/http/codes.d.tl
Normal file
2
teal-src/net/http/codes.d.tl
Normal file
|
@ -0,0 +1,2 @@
|
|||
local type response_codes = { integer : string }
|
||||
return response_codes
|
22
teal-src/net/http/errors.d.tl
Normal file
22
teal-src/net/http/errors.d.tl
Normal file
|
@ -0,0 +1,22 @@
|
|||
local record http_errors
|
||||
enum known_conditions
|
||||
"cancelled"
|
||||
"connection-closed"
|
||||
"certificate-chain-invalid"
|
||||
"certificate-verify-failed"
|
||||
"connection failed"
|
||||
"invalid-url"
|
||||
"unable to resolve service"
|
||||
end
|
||||
type registry_keys = known_conditions | integer
|
||||
record error
|
||||
type : string
|
||||
condition : string
|
||||
code : integer
|
||||
text : string
|
||||
end
|
||||
registry : { registry_keys : error }
|
||||
new : function (integer, known_conditions, table)
|
||||
new : function (integer, string, table)
|
||||
end
|
||||
return http_errors
|
14
teal-src/net/http/files.d.tl
Normal file
14
teal-src/net/http/files.d.tl
Normal file
|
@ -0,0 +1,14 @@
|
|||
local record serve_options
|
||||
path : string
|
||||
mime_map : { string : string }
|
||||
cache_size : integer
|
||||
cache_max_file_size : integer
|
||||
index_files : { string }
|
||||
directory_index : boolean
|
||||
end
|
||||
|
||||
local record http_files
|
||||
serve : function(serve_options|string) : function
|
||||
end
|
||||
|
||||
return http_files
|
58
teal-src/net/http/parser.d.tl
Normal file
58
teal-src/net/http/parser.d.tl
Normal file
|
@ -0,0 +1,58 @@
|
|||
local record httpstream
|
||||
feed : function(httpstream, string)
|
||||
end
|
||||
|
||||
local type sink_cb = function ()
|
||||
|
||||
local record httppacket
|
||||
enum http_method
|
||||
"HEAD"
|
||||
"GET"
|
||||
"POST"
|
||||
"PUT"
|
||||
"DELETE"
|
||||
"OPTIONS"
|
||||
-- etc
|
||||
end
|
||||
method : http_method
|
||||
record url_details
|
||||
path : string
|
||||
query : string
|
||||
end
|
||||
url : url_details
|
||||
path : string
|
||||
enum http_version
|
||||
"1.0"
|
||||
"1.1"
|
||||
end
|
||||
httpversion : http_version
|
||||
headers : { string : string }
|
||||
body : string | boolean
|
||||
body_sink : sink_cb
|
||||
chunked : boolean
|
||||
partial : boolean
|
||||
end
|
||||
|
||||
local enum error_conditions
|
||||
"cancelled"
|
||||
"connection-closed"
|
||||
"certificate-chain-invalid"
|
||||
"certificate-verify-failed"
|
||||
"connection failed"
|
||||
"invalid-url"
|
||||
"unable to resolve service"
|
||||
end
|
||||
|
||||
local type success_cb = function (httppacket)
|
||||
local type error_cb = function (error_conditions)
|
||||
|
||||
local enum stream_mode
|
||||
"client"
|
||||
"server"
|
||||
end
|
||||
|
||||
local record lib
|
||||
new : function (success_cb, error_cb, stream_mode) : httpstream
|
||||
end
|
||||
|
||||
return lib
|
6
teal-src/net/http/server.d.tl
Normal file
6
teal-src/net/http/server.d.tl
Normal file
|
@ -0,0 +1,6 @@
|
|||
|
||||
local record http_server
|
||||
-- TODO
|
||||
end
|
||||
|
||||
return http_server
|
Loading…
Add table
Add a link
Reference in a new issue