Complete Suite of Embedded Web Development ToolsStandalone Tools for Embedded Development
IoT Protocols
Quick Look
|
The PikeHTTP client enables embedded devices to communicate with any web server and to upload and download any type of data. Devices can independently retrieve files such as configuration files and software updates, enabling large arrays of devices to be updated simultaneously without direct, one-by-one reconfiguration. FEATURES:
The Barracuda Application Server includes PikeHTTP |
The PikeHTTP C library comes as a pre-integrated component of the Barracuda Application Server and includes Lua bindings (Lua to C connector), making it easy to use the HTTP client library from Lua code.
The following Lua example shows how to send JSON data as part of the HTTP body to a JSON echo service. The service responds with the original data and additional JSON data.
Click the Run button below the source code
<?lsp response:setcontenttype"text/plain" local rdata -- rec data local sdata={ -- data to send hello = "world", vector = { i=10, j=15 } } local http = require"httpc".create() local ok,err=http:request{ url="https://postman-echo.com/post", method="POST", header={["Content-Type"]="application/json; charset=utf-8"} } if ok then ok,err=http:write(ba.json.encode(sdata)) if ok then rdata,err=http:read"*a" end end if rdata then print("Rec Data:", rdata) print("Valid JSON: ", ba.json.decode(rdata) and "yes" or "no") else print("Err:",err) end ?>