“LlHTTPResponse”的版本间的差异
| 第68行: | 第68行: | ||
} | } | ||
} | } | ||
| − | <pre> | + | </pre> |
2020年8月20日 (四) 10:12的最新版本
| 首页 | 函数 | 事件 | 类型 | 操作符 | 常数 | Flow Control | Script Library | Categorized Library | Tutorials |
| 函数名 |
|---|
| Function: llHTTPResponse( key request_id, integer status, string body ); |
| 参数:
key request_id – A valid HTTP request key. integer status – HTTP Status (200, 400, 404, etc) string body – Contents of the response. |
| 返回值:用 status 和 body 响应 request _ id。 |
| 注意事项 |
|---|
*This call must be made by the script containing the http_request event where the request_id was received.
在接收脚本时,llhttprequest 可以截断响应长度。在使用它们进行 prim-to-prim 通信时要注意。
|
| 示例 |
|---|
示例一
string url;
default
{
changed(integer change)
{
if (change & (CHANGED_REGION_START|CHANGED_REGION | CHANGED_TELEPORT))
llResetScript();
}
state_entry()
{
llRequestURL();
}
touch_start(integer num_detected)
{
// PUBLIC_CHANNEL has the integer value 0
if (url != "")
llSay(PUBLIC_CHANNEL, "URL: " + url);
}
http_request(key id, string method, string body)
{
// http://en.wikipedia.org/wiki/Create,_read,_update_and_delete
list CRUDmethods = ["GET", "POST", "PUT", "DELETE"];
// it's bit-wise NOT ( ~ ) !!!
integer isAllowedMethod = ~llListFindList(CRUDmethods, [method]);
if (isAllowedMethod)
{
llHTTPResponse(id, 200, "Body of request below:\n" + body);
}
else if (method == URL_REQUEST_GRANTED)
{
// don't forget the trailing slash
url = body + "/";
llOwnerSay("URL: " + url);
}
else if (method == URL_REQUEST_DENIED)
{
llOwnerSay("Something went wrong, no URL.\n" + body);
}
else
{
llOwnerSay("Ummm... I have no idea what SL just did. Method=\""+method+"\"\n" + body);
}
}
}
|
| 相关函数 |
|---|
| llGetFreeURLs
llRequestURL llRequestSecureURL llReleaseURL llGetHTTPHeader llSetConteneType |
| 相关事件 |
|---|
| http request |