Sets the Internet media type header of any subsequent LSL HTTP server response via llHTTPResponse."Content-Type"
void llSetContentType( key request_id, integer content_type );
Energy: ?.
| content_type | Content-Type | |
|---|---|---|
| CONTENT_TYPE_TEXT | 0 | text/plain |
| CONTENT_TYPE_HTML | 1 | text/html |
| CONTENT_TYPE_XML | 2 | application/xml |
| CONTENT_TYPE_XHTML | 3 | application/xhtml+xml |
| CONTENT_TYPE_ATOM | 4 | application/atom+xml |
| CONTENT_TYPE_JSON | 5 | application/json |
| CONTENT_TYPE_LLSD | 6 | application/llsd+xml |
| CONTENT_TYPE_FORM | 7 | application/x-www-form-urlencoded |
| CONTENT_TYPE_RSS | 8 | application/rss+xml |
key url_request;
string HTML_BODY =
"<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>";
default
{
state_entry()
{
url_request = llRequestURL();
}
http_request(key id, string method, string body)
{
key owner = llGetOwner();
vector ownerSize = llGetAgentSize(owner);
if (url_request == id)
{
// if you're usually not resetting the query ID
// now is a good time to start!
url_request = "";
if (method == URL_REQUEST_GRANTED)
{
llOwnerSay("URL: " + body);
// if owner in sim
if (ownerSize)// != ZERO_VECTOR
llLoadURL(owner, "I got a new URL!", body);
}
else if (method == URL_REQUEST_DENIED)
llOwnerSay("Something went wrong, no url:\n" + body);
}
else
{
llOwnerSay("request body:\n" + body);
// if owner in sim
if (ownerSize)// != ZERO_VECTOR
{
llSetContentType(id, CONTENT_TYPE_HTML);
llHTTPResponse(id, 200, HTML_BODY);
}
else
{
llSetContentType(id, CONTENT_TYPE_TEXT);
llHTTPResponse(id, 200, "OK");
}
}
}
}
The client and owner limitations are most likely to remove the possibility of running a website from a prim.