https function - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: https function (/showthread.php?tid=3184) |
https function - benanderson_475 - 19.02.2021 i make dynamic function to call https command and to add headers like the below, Code: function Https_message(method, url, payload, add_headers) --method is "POST", "GET" "PUT" etc My problem is, if i call get command like Code: local msg_response, err, Https_message('GET', 192.168.1.1:443/etc/etc, nil, nil) i think because, source = ltn12.source.string(payload) would be nil 2 Questions 1- Is the ltn12.source tied together with the ltn12.sink if the source var is present? 2- How can i ignore the ltn12.source if function payload var is set to nil? RE: https function - admin - 22.02.2021 Do not set the source if payload is not provided: Code: local source There's another issue with your code when payload or add_headers are set: ip/port variables are not set, so the function call will produce an error. You can use socket.url to parse the url into parts: http://w3.impa.br/~diego/software/luasocket/url.html#parse |