[skip ci] http and https test scripts

This commit is contained in:
Syping 2020-07-06 06:15:30 +02:00
parent 0fd63c62e3
commit 4485b2b4eb
2 changed files with 34 additions and 2 deletions

View File

@ -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
View 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