blob: 9135ec12ed2583199f63ff5cb69f8c1b0b5cd913 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
local Promise = require "util.promise".Promise;
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
|