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