mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-11-05 05:26:55 +01:00
[skip ci] http and https test scripts
This commit is contained in:
parent
0fd63c62e3
commit
4485b2b4eb
2 changed files with 34 additions and 2 deletions
|
@ -20,12 +20,12 @@ end
|
|||
|
||||
function socketConnected(socket)
|
||||
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)
|
||||
end
|
||||
|
||||
function socketReadyRead(socket)
|
||||
setObjectText(globalLabel, "<b>Reading...</b>")
|
||||
local readData = eIOReadAll(socket)
|
||||
setObjectText(globalLabel, "<!DOCTYPE html>" .. readData)
|
||||
setObjectText(globalLabel, readData)
|
||||
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