teal-src/net/http.d.tl
author Matthew Wild <mwild1@gmail.com>
Thu, 06 Oct 2022 18:34:40 +0100
changeset 12748 e894677359e5
parent 12616 588b1d175838
permissions -rw-r--r--
util.iterators: join: Work even with only a single iterator in the chain
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12616
588b1d175838 util.promise: Add Teal interface specification file
Kim Alvefur <zash@zash.se>
parents: 12613
diff changeset
     1
local Promise = require "util.promise".Promise;
12613
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
     2
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
     3
local record sslctx -- from LuaSec
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
     4
end
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
     5
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
     6
local record lib
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
     7
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
     8
	enum http_method
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
     9
		"GET"
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    10
		"HEAD"
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    11
		"POST"
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    12
		"PUT"
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    13
		"OPTIONS"
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    14
		"DELETE"
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    15
		-- etc?
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    16
	end
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    17
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    18
	record http_client_options
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    19
		sslctx : sslctx
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    20
	end
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    21
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    22
	record http_options
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    23
		id : string
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    24
		onlystatus : boolean
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    25
		body : string
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    26
		method : http_method
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    27
		headers : { string : string }
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    28
		insecure : boolean
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    29
		suppress_errors : boolean
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    30
		streaming_handler : function
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    31
		suppress_url : boolean
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    32
		sslctx : sslctx
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    33
	end
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    34
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    35
	record http_request
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    36
		host : string
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    37
		port : string
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    38
		enum scheme
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    39
			"http"
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    40
			"https"
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    41
		end
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    42
		scheme : scheme
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    43
		url : string
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    44
		userinfo : string
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    45
		path : string
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    46
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    47
		method : http_method
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    48
		headers : { string : string }
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    49
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    50
		insecure : boolean
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    51
		suppress_errors : boolean
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    52
		streaming_handler : function
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    53
		http : http_client
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    54
		time : integer
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    55
		id : string
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    56
		callback : http_callback
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    57
	end
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    58
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    59
	record http_response
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    60
	end
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    61
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    62
	type http_callback = function (string, number, http_response, http_request)
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    63
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    64
	record http_client
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    65
		options : http_client_options
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    66
		request : function (http_client, string, http_options, http_callback)
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    67
	end
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    68
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    69
	request : function (string, http_options, http_callback) : Promise, string
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    70
	default : http_client
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    71
	new : function (http_client_options) : http_client
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    72
	events : table
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    73
	-- COMPAT
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    74
	urlencode : function (string) : string
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    75
	urldecode : function (string) : string
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    76
	formencode : function ({ string : string }) : string
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    77
	formdecode : function (string) : { string : string }
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    78
	destroy_request : function (http_request)
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    79
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    80
	enum available_features
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    81
		"sni"
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    82
	end
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    83
	features : { available_features : boolean }
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    84
end
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    85
a8eb838fc6cf net.http: Add teal description files
Kim Alvefur <zash@zash.se>
parents:
diff changeset
    86
return lib