Skip to content

chenweiqi/lua_httpsc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lua_httpsc

A non-blocking https client library for lua, it also support blocking request, http request

API

httpsc = require "httpsc"

Connect remote https server

local ip = "127.0.0.1"
local port = 443

fd = httpsc.connect(ip, port)
-- fd = httpsc.connect(ip, port, "http")
-- fd = httpsc.connect(ip, port, "https")

Check connection is ready, only for non-blocking request

-- Check connection
while true do
	local ok = httpsc.check_connect(fd)
	if ok then break end
	httpsc.usleep(10000)
end

Write data to remote

httpsc.send(fd, msg)

Receive data from remote

httpsc.recv(fd, size)       -- size is optional

Set configure

httpsc.set_conf({
	init_lib = true,	-- load openssl libary, default: true
	async = true,		-- work under non-blocking, default: true
	send_timeout = 10000,	-- socket send timeout, default: 10000 (10 second)
	recv_timeout = 10000,	-- socket recv timeout, default: 10000 (10 second)
})

Example

See test.lua

About

A non-blocking https client library for lua, it also support blocking request, http

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published