Https.request simple and generic forms


#1

I have been using this simple https.request format with success in my AAF application.

local res, code, headers, status = https.request(“https://myserver/modem_scripts/modemUpdate.php”,sendString)

The source in this case a string “sendString” is sent as a POST request using the default configuration of

default = {
protocol = "tlsv1",
options = "all",
verify = "none",
}

As TLSv1 is deprecated and unsecure I wanted to modify the request to use TLSv1.2 . This requires the generic form of the request which is LTN12 based.

The generic form is now:

local res, code, headers, status = https.request({
url = “https://myserver/modem_scripts/modemUpdate.php”,
protocol = ‘tlsv1_2’,
method = ‘POST’,
headers = {
[“content-type”] = “application/x-www-form-urlencoded”,
[“content-length”] = string.len(sendString)
},
sink = ltn12.sink.file(io.stdout),
source = ltn12.source.string(sendString)
})

References
LuaSocket HTTP support
LuaSocket LTN12 module