mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-05-21 05:25:52 +02:00
[skip ci] http and https test scripts
This commit is contained in:
parent
0fd63c62e3
commit
4485b2b4eb
|
@ -20,12 +20,12 @@ end
|
||||||
|
|
||||||
function socketConnected(socket)
|
function socketConnected(socket)
|
||||||
setObjectText(globalLabel, "<b>Connected!</b>")
|
setObjectText(globalLabel, "<b>Connected!</b>")
|
||||||
eIOWrite(socket, "GET /luaenginetest.html HTTP/1.1\r\nHost: www.syping.de\r\nUser-Agent: LuaEngine\r\nConnection: close\r\n\r\n")
|
eIOWrite(socket, "GET / HTTP/1.1\r\nHost: www.syping.de\r\nUser-Agent: LuaEngine\r\nConnection: close\r\n\r\n")
|
||||||
socketFlush(socket)
|
socketFlush(socket)
|
||||||
end
|
end
|
||||||
|
|
||||||
function socketReadyRead(socket)
|
function socketReadyRead(socket)
|
||||||
setObjectText(globalLabel, "<b>Reading...</b>")
|
setObjectText(globalLabel, "<b>Reading...</b>")
|
||||||
local readData = eIOReadAll(socket)
|
local readData = eIOReadAll(socket)
|
||||||
setObjectText(globalLabel, "<!DOCTYPE html>" .. readData)
|
setObjectText(globalLabel, readData)
|
||||||
end
|
end
|
32
tests/network/https.lua
Normal file
32
tests/network/https.lua
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
local globalLabel
|
||||||
|
|
||||||
|
function main()
|
||||||
|
-- Window
|
||||||
|
mainWindow = createMainWindow("LE TCP Test")
|
||||||
|
local mainLayout = createLayout(VerticalLayout, mainWindow)
|
||||||
|
|
||||||
|
local socket = createTcpSocket()
|
||||||
|
connect(socket, "connected()", "socketConnected")
|
||||||
|
connect(socket, "readyRead()", "socketReadyRead")
|
||||||
|
socketConnect(socket, "syping.de:443")
|
||||||
|
|
||||||
|
globalLabel = createLabel("<b>Connecting...</b>", mainLayout)
|
||||||
|
|
||||||
|
-- Show Window
|
||||||
|
setWidgetSize(mainWindow, 650, 450)
|
||||||
|
showWidget(mainWindow, ShowDefault)
|
||||||
|
return GuiExecuted
|
||||||
|
end
|
||||||
|
|
||||||
|
function socketConnected(socket)
|
||||||
|
setObjectText(globalLabel, "<b>Connected!</b>")
|
||||||
|
tcpSocketStartTLS(socket)
|
||||||
|
eIOWrite(socket, "GET / HTTP/1.1\r\nHost: www.syping.de\r\nUser-Agent: LuaEngine\r\nConnection: close\r\n\r\n")
|
||||||
|
socketFlush(socket)
|
||||||
|
end
|
||||||
|
|
||||||
|
function socketReadyRead(socket)
|
||||||
|
setObjectText(globalLabel, "<b>Reading...</b>")
|
||||||
|
local readData = eIOReadAll(socket)
|
||||||
|
setObjectText(globalLabel, readData)
|
||||||
|
end
|
Loading…
Reference in a new issue