2023-02-04 00:27:56 +00:00
|
|
|
local RESPONSE = "Hello, lune!"
|
|
|
|
|
|
|
|
task.spawn(function()
|
|
|
|
net.serve(8080, function(request)
|
2023-02-06 03:25:36 +00:00
|
|
|
-- info("Request:", request)
|
|
|
|
-- info("Responding with", RESPONSE)
|
2023-02-08 02:54:52 +00:00
|
|
|
assert(request.path == "/some/path")
|
|
|
|
assert(request.query.key == "param2")
|
2023-02-04 00:27:56 +00:00
|
|
|
return RESPONSE
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2023-02-08 02:54:52 +00:00
|
|
|
local response = net.request("http://127.0.0.1:8080/some/path?key=param1&key=param2").body
|
2023-02-04 00:27:56 +00:00
|
|
|
assert(response == RESPONSE, "Invalid response from server")
|
|
|
|
|
|
|
|
task.delay(1, function()
|
|
|
|
process.exit(0)
|
|
|
|
end)
|
|
|
|
|
|
|
|
task.delay(2, function()
|
2023-02-06 03:25:36 +00:00
|
|
|
error("Process did not exit")
|
2023-02-04 00:27:56 +00:00
|
|
|
end)
|