escape(str:string)call to curl_escape
unescape(str:string)call to curl_unescape
cookiejar(path:string)set the default cookiejar path
cainfo(path:string)set the default cainfo path
capath(path:string)set the default capath path
get(arg:table or string)post(arg:table or string)put(arg:table or string)head(arg:table or string)update(arg:table or string)delete(arg:table or string)if arg is string, use it as url key in the following arg table.
keys in the arg:
url: string
the url path string
headers: table?
the request headers, format {key = value, key2 = value2}
verbose: boolean?
save all request message to file named verbose.log
dns_servers: string?
customize the dns servers, format 1.2.3.4,2.3.4.5, refer to CURLOPT_DNS_SERVERS
onprogress: function?
progress callback, arg1 => dltotal:integer, arg2 => dlnow:integer, arg3 => ultotal:integer, arg4 => ulnow:integer, refer to CURLOPT_PROGRESSFUNCTION
timeout: number?
low speed timeout, less than 0 in 1min, refer to CURLOPT_LOW_SPEED_TIME
conntimeout: number?
connection timeout, CURLOPT_TIMEOUT
ssl_verifypeer: integer?, refer to CURLOPT_SSL_VERIFYPEER
ssl_verifyhost: integer?, refer to CURLOPT_SSL_VERIFYHOST
sslcert: string?, refer to CURLOPT_SSLCERT
sslcertpasswd: string?, refer to CURLOPT_SSLCERTPASSWD
sslcerttype: string?, refer to CURLOPT_SSLCERTTYPE
sslkey: string?, refer to CURLOPT_SSLKEY
sslkeypasswd: string?, refer to CURLOPT_SSLKEYPASSWD
sslkeytype: string?, refer to CURLOPT_SSLKEYTYPE
cainfo: string?, refer to CURLOPT_CAINFO
capath: string?, refer to CURLOPT_CAPATH
proxytunnel: integer?, refer to CURLOPT_HTTPPROXYTUNNEL
proxy: string?, refer to CURLOPT_PROXY, HTTP proxy only.
One-shot form is supported: http://user:pass@host:port (libcurl parses
scheme/userinfo/host/port). Host-only also works with proxyport below.
proxyport: integer?, refer to CURLOPT_PROXYPORT (optional if port is already in proxy URL)
proxyuser: string?, refer to CURLOPT_PROXYUSERNAME (optional if userinfo is already in proxy URL)
proxypassword: string?, refer to CURLOPT_PROXYPASSWORD (optional if userinfo is already in proxy URL)
onsend: function?
callback for data upload, refer to CURLOPT_READFUNCTION
body: string?
full body for data to be sent, available if onsend not defined.
onreceive: function?
callback on receive data from remote, if not set, get the response body from reponsetable.body, arg1 => data:string
onheader: function?
callback on receive the header part, arg1 => header:table
oncomplete: function?
callback on http request complete, the http operation return nothing, if not set, the http operation return the responsetable only the request completed. arg1 => responsetable:table
forbid_reuse: integer? forbidden connection reuse on http/1.1, refer to CURLOPT_FORBID_REUSE
cookiejar: string?
cookiejar used by this request, refer to CURLOPT_COOKIEJAR,CURLOPT_COOKIEFILE
The Lua fan.http.http implementation accepts worker and forwards it to fan.connector.tcp, so its request connection uses the selected event base: omitted keeps the connection on the main base, while an explicit worker selects that worker. This applies to the Lua HTTP implementation only.
The core fan.http client (C implementation) now owns one libcurl multi handle, timer events, socket events and in-flight list per event runtime: the main base plus one runtime per event worker. It accepts worker with these rules:
worker = -1 — explicitly selects the main runtime (rejected from a worker thread);worker = N (>= 0) — selects worker N’s runtime and must match the current event worker; a mismatch is an error.The curl_share handle (DNS/SSL session/connect cache) is still process-wide and is serialized by its own recursive lock.
keys in the responsetable:
responseCode: integer
response code of this request, available on onheader callback also.
body: string
response body, available on onreceive callback not set.
headers: table
response headers, format as {singlekey = "value", multikey = {"value1", "value2"}}
cookies: table
list of cookies.
error: string
error during request, must check this to make sure http request fully complete.