Files
prim-dns-server/request-handler.lsl

24 lines
1.2 KiB
Plaintext
Raw Normal View History

2023-01-13 19:41:11 -05:00
string jsonrpc_notification(string method, string params_type, list params)
2023-01-10 12:07:25 -05:00
{
2023-01-13 19:41:11 -05:00
return llList2Json(JSON_OBJECT, ["jsonrpc", "2.0", "method", method, "params", llList2Json(params_type, params)]);
2023-01-09 14:38:12 -05:00
}
default
{
link_message(integer sender, integer num, string str, key id)
{
2023-01-13 19:41:11 -05:00
string jsonrpc_method = llJsonGetValue(str, ["method"]);
if (jsonrpc_method == "prim-dns:request")
2023-01-09 14:38:12 -05:00
{
2023-01-13 19:41:11 -05:00
key request_id = (key) llJsonGetValue(str, ["params", "request-id"]);
string method = llJsonGetValue(str, ["params", "method"]);
string headers = llJsonGetValue(str, ["params", "headers"]);
string body = llJsonGetValue(str, ["params", "body"]);
2023-01-13 21:14:20 -05:00
llMessageLinked(sender, 0, jsonrpc_notification("prim-dns:set-content-type", JSON_OBJECT, ["request-id", request_id, "content-type", CONTENT_TYPE_XHTML]), NULL_KEY);
llMessageLinked(sender, 0, jsonrpc_notification("prim-dns:response", JSON_OBJECT, ["request-id", request_id, "status", 200, "body", "<html xmlns=\"http://www.w3.org/1999/xhtml\"><body style=\"background-color: black; color: green; font-family: monospace;\"><b>Hello, world!</b></body></html>"]), NULL_KEY);
2023-01-09 14:38:12 -05:00
}
}
}